diff --git a/CHANGELOG.md b/CHANGELOG.md index e0791764..47cce143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * chore: Fix static analysis issues. * refactor: Change context array to `Context` object. * refactor: Move `Context` to its own namespace. +* style(Context): Rename `set` to `with` and `remove` to `without`. ## 0.5.4 diff --git a/src/Context/Context.php b/src/Context/Context.php index cb34903e..0af509b0 100644 --- a/src/Context/Context.php +++ b/src/Context/Context.php @@ -14,7 +14,6 @@ namespace Rekalogika\Mapper\Context; use Rekalogika\Mapper\Exception\LogicException; -use Rekalogika\Mapper\Context\ContextMemberNotFoundException; /** * @immutable @@ -42,7 +41,7 @@ private static function createFrom(array $context): self return new self($context); } - public function add(object $value): self + public function with(object $value): self { $class = get_class($value); @@ -56,7 +55,7 @@ public function add(object $value): self return self::createFrom($context); } - public function remove(object|string $value): self + public function without(object|string $value): self { $class = is_string($value) ? $value : get_class($value); diff --git a/src/MainTransformer/MainTransformer.php b/src/MainTransformer/MainTransformer.php index 21aba2ce..08dc8497 100644 --- a/src/MainTransformer/MainTransformer.php +++ b/src/MainTransformer/MainTransformer.php @@ -14,8 +14,8 @@ namespace Rekalogika\Mapper\MainTransformer; use Rekalogika\Mapper\Context\Context; -use Rekalogika\Mapper\MainTransformer\Exception\CannotFindTransformerException; use Rekalogika\Mapper\Context\ContextMemberNotFoundException; +use Rekalogika\Mapper\MainTransformer\Exception\CannotFindTransformerException; use Rekalogika\Mapper\MainTransformer\Exception\TransformerReturnsUnexpectedValueException; use Rekalogika\Mapper\ObjectCache\Exception\CachedTargetObjectNotFoundException; use Rekalogika\Mapper\ObjectCache\ObjectCache; @@ -90,7 +90,7 @@ public function transform( $objectCache = $context->get(ObjectCache::class); } catch (ContextMemberNotFoundException) { $objectCache = $this->objectCacheFactory->createObjectCache(); - $context = $context->add($objectCache); + $context = $context->with($objectCache); } // gets simple target types from the provided target type diff --git a/src/Mapper.php b/src/Mapper.php index ed11421e..a1c8a9cf 100644 --- a/src/Mapper.php +++ b/src/Mapper.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper; -use Rekalogika\Mapper\Exception\UnexpectedValueException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\UnexpectedValueException; use Rekalogika\Mapper\MainTransformer\MainTransformerInterface; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/MethodMapper/ClassMethodTransformer.php b/src/MethodMapper/ClassMethodTransformer.php index 2a00c969..3a872097 100644 --- a/src/MethodMapper/ClassMethodTransformer.php +++ b/src/MethodMapper/ClassMethodTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\MethodMapper; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/src/MethodMapper/SubMapper.php b/src/MethodMapper/SubMapper.php index 61408825..09eeb7e2 100644 --- a/src/MethodMapper/SubMapper.php +++ b/src/MethodMapper/SubMapper.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\MethodMapper; -use Rekalogika\Mapper\Exception\UnexpectedValueException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\UnexpectedValueException; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/Transformer/ArrayToObjectTransformer.php b/src/Transformer/ArrayToObjectTransformer.php index 0d5006a4..8915ad84 100644 --- a/src/Transformer/ArrayToObjectTransformer.php +++ b/src/Transformer/ArrayToObjectTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Transformer\Exception\InvalidTypeInArgumentException; diff --git a/src/Transformer/DateTimeTransformer.php b/src/Transformer/DateTimeTransformer.php index 0fe7ca4d..794e5eab 100644 --- a/src/Transformer/DateTimeTransformer.php +++ b/src/Transformer/DateTimeTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeCheck; diff --git a/src/Transformer/NullTransformer.php b/src/Transformer/NullTransformer.php index e86c7df9..2eac0b89 100644 --- a/src/Transformer/NullTransformer.php +++ b/src/Transformer/NullTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeCheck; diff --git a/src/Transformer/ObjectToArrayTransformer.php b/src/Transformer/ObjectToArrayTransformer.php index df8f1ace..ac78ea08 100644 --- a/src/Transformer/ObjectToArrayTransformer.php +++ b/src/Transformer/ObjectToArrayTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/Transformer/ObjectToObjectTransformer.php b/src/Transformer/ObjectToObjectTransformer.php index 156b57a4..4914c115 100644 --- a/src/Transformer/ObjectToObjectTransformer.php +++ b/src/Transformer/ObjectToObjectTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/src/Transformer/ObjectToStringTransformer.php b/src/Transformer/ObjectToStringTransformer.php index eb698bd7..1b856f75 100644 --- a/src/Transformer/ObjectToStringTransformer.php +++ b/src/Transformer/ObjectToStringTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeFactory; diff --git a/src/Transformer/ScalarToScalarTransformer.php b/src/Transformer/ScalarToScalarTransformer.php index f0da9203..f69375a2 100644 --- a/src/Transformer/ScalarToScalarTransformer.php +++ b/src/Transformer/ScalarToScalarTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Util\TypeCheck; diff --git a/src/Transformer/StringToBackedEnumTransformer.php b/src/Transformer/StringToBackedEnumTransformer.php index a3db1aec..056a6405 100644 --- a/src/Transformer/StringToBackedEnumTransformer.php +++ b/src/Transformer/StringToBackedEnumTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping; use Rekalogika\Mapper\Transformer\Exception\InvalidTypeInArgumentException; diff --git a/src/Transformer/TraversableToArrayAccessTransformer.php b/src/Transformer/TraversableToArrayAccessTransformer.php index d9757318..89e9fc12 100644 --- a/src/Transformer/TraversableToArrayAccessTransformer.php +++ b/src/Transformer/TraversableToArrayAccessTransformer.php @@ -15,8 +15,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/src/Transformer/TraversableToTraversableTransformer.php b/src/Transformer/TraversableToTraversableTransformer.php index 84762327..992de79a 100644 --- a/src/Transformer/TraversableToTraversableTransformer.php +++ b/src/Transformer/TraversableToTraversableTransformer.php @@ -13,8 +13,8 @@ namespace Rekalogika\Mapper\Transformer; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\ObjectCache\ObjectCache; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareInterface; use Rekalogika\Mapper\Transformer\Contracts\MainTransformerAwareTrait; diff --git a/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php b/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php index c846fa17..acb6a69d 100644 --- a/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php +++ b/tests/Fixtures/Transformer/MoneyToMoneyDtoTransformer.php @@ -14,8 +14,8 @@ namespace Rekalogika\Mapper\Tests\Fixtures\Transformer; use Brick\Money\Money; -use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Context\Context; +use Rekalogika\Mapper\Exception\InvalidArgumentException; use Rekalogika\Mapper\Tests\Fixtures\Money\MoneyDto; use Rekalogika\Mapper\Transformer\Contracts\TransformerInterface; use Rekalogika\Mapper\Transformer\Contracts\TypeMapping;