diff --git a/src/UtmParameters.php b/src/UtmParameters.php index ccf2d94..25ae1cb 100644 --- a/src/UtmParameters.php +++ b/src/UtmParameters.php @@ -4,6 +4,7 @@ namespace Devlop\UtmParameters; +use ArrayIterator; use DateInterval; use DateTimeImmutable; use DateTimeInterface; @@ -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'; @@ -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 *