Skip to content

Commit

Permalink
Implement IteratorAggregate interface
Browse files Browse the repository at this point in the history
  • Loading branch information
johanrosenson committed Feb 10, 2021
1 parent c9bfcb4 commit 3fe69d5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/UtmParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Devlop\UtmParameters;

use ArrayIterator;
use DateInterval;
use DateTimeImmutable;
use DateTimeInterface;
Expand All @@ -14,9 +15,10 @@
use Devlop\UtmParameters\RequestHandlerInterface;
use Devlop\UtmParameters\ResponseHandlerInterface;
use InvalidArgumentException;
use IteratorAggregate;
use Webmozart\Assert\Assert;

final class UtmParameters implements UtmParametersFactoryInterface, UtmParametersInterface
final class UtmParameters implements UtmParametersFactoryInterface, UtmParametersInterface, IteratorAggregate
{
public const SOURCE = 'utm_source';

Expand Down Expand Up @@ -259,6 +261,16 @@ public function getContent() : ?string
return $this->content;
}

/**
* Required by the IteratorAggregate interface.
*
* Returns an external iterator.
*/
public function getIterator() : ArrayIterator
{
return new ArrayIterator($this->toArray());
}

/**
* Get all parameters as a key => value array
*
Expand Down

0 comments on commit 3fe69d5

Please sign in to comment.