diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c71df9c..d602d46b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * feat: Supports dynamic properties (including `stdClass`) on the target side. * fix(`Mapper`): Fix typehint. * test: test array cast to object mapping +* feat(`Context`): `with()` not accepts multiple argument. ## 1.0.0 diff --git a/src/Context/Context.php b/src/Context/Context.php index 58a859ac..c16ad4f3 100644 --- a/src/Context/Context.php +++ b/src/Context/Context.php @@ -56,11 +56,14 @@ private static function createFrom(array $context): self return new self($context); } - public function with(object $value): self + public function with(object ...$value): self { - $class = get_class($value); $context = $this->context; - $context[$class] = $value; + + foreach ($value as $object) { + $class = get_class($object); + $context[$class] = $object; + } return self::createFrom($context); }