Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/Response/Stream/StreamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)),
Expand Down
8 changes: 4 additions & 4 deletions tests/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions tests/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
13 changes: 9 additions & 4 deletions tests/Models/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -25,4 +25,9 @@ public function getIterator(): Traversable
{
return new ArrayIterator($this->elements);
}

public function getType(): string
{
return Product::class;
}
}
Loading