diff --git a/Makefile b/Makefile index 81f8617..96ccd27 100644 --- a/Makefile +++ b/Makefile @@ -35,4 +35,4 @@ show-reports: clean: @sudo chown -R ${USER}:${USER} ${PWD} - @rm -rf report vendor .phpunit.cache .lock + @rm -rf report vendor .phpunit.cache *.lock diff --git a/composer.json b/composer.json index e8a57de..c40f22d 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "require": { "php": "^8.3", "psr/http-message": "^1.1", - "tiny-blocks/serializer": "^3", + "tiny-blocks/mapper": "^1", "ext-mbstring": "*" }, "require-dev": { diff --git a/src/Internal/Response/Stream/StreamFactory.php b/src/Internal/Response/Stream/StreamFactory.php index 947e124..5686d35 100644 --- a/src/Internal/Response/Stream/StreamFactory.php +++ b/src/Internal/Response/Stream/StreamFactory.php @@ -6,7 +6,7 @@ use BackedEnum; use Psr\Http\Message\StreamInterface; -use TinyBlocks\Serializer\Serializer; +use TinyBlocks\Mapper\Mapper; use UnitEnum; final readonly class StreamFactory @@ -21,7 +21,7 @@ private function __construct(private mixed $body) public static function fromBody(mixed $body): StreamFactory { $dataToWrite = match (true) { - is_a($body, Serializer::class) => $body->toJson(), + is_a($body, Mapper::class) => $body->toJson(), is_a($body, BackedEnum::class) => self::toJsonFrom(body: $body->value), is_a($body, UnitEnum::class) => $body->name, is_object($body) => self::toJsonFrom(body: get_object_vars($body)), diff --git a/tests/Models/Order.php b/tests/Models/Order.php index 373db4e..172e47d 100644 --- a/tests/Models/Order.php +++ b/tests/Models/Order.php @@ -4,12 +4,12 @@ namespace TinyBlocks\Http\Models; -use TinyBlocks\Serializer\Serializer; -use TinyBlocks\Serializer\SerializerAdapter; +use TinyBlocks\Mapper\ObjectMappability; +use TinyBlocks\Mapper\ObjectMapper; -final readonly class Order implements Serializer +final readonly class Order implements ObjectMapper { - use SerializerAdapter; + use ObjectMappability; public function __construct(public int $id, public Products $products) { diff --git a/tests/Models/Product.php b/tests/Models/Product.php index bccdcf5..6cd2b75 100644 --- a/tests/Models/Product.php +++ b/tests/Models/Product.php @@ -4,12 +4,12 @@ namespace TinyBlocks\Http\Models; -use TinyBlocks\Serializer\Serializer; -use TinyBlocks\Serializer\SerializerAdapter; +use TinyBlocks\Mapper\ObjectMappability; +use TinyBlocks\Mapper\ObjectMapper; -final readonly class Product implements Serializer +final readonly class Product implements ObjectMapper { - use SerializerAdapter; + use ObjectMappability; public function __construct(public string $name, public Amount $amount) { diff --git a/tests/Models/Products.php b/tests/Models/Products.php index 32c2bec..d092f02 100644 --- a/tests/Models/Products.php +++ b/tests/Models/Products.php @@ -6,13 +6,13 @@ use ArrayIterator; use IteratorAggregate; -use TinyBlocks\Serializer\Serializer; -use TinyBlocks\Serializer\SerializerAdapter; +use TinyBlocks\Mapper\IterableMappability; +use TinyBlocks\Mapper\IterableMapper; use Traversable; -final class Products implements Serializer, IteratorAggregate +final class Products implements IterableMapper, IteratorAggregate { - use SerializerAdapter; + use IterableMappability; private array $elements; @@ -25,4 +25,9 @@ public function getIterator(): Traversable { return new ArrayIterator($this->elements); } + + public function getType(): string + { + return Product::class; + } }