From b58f1871b7c9b283fe551774999cecb31dbc50da Mon Sep 17 00:00:00 2001 From: fab2s Date: Sat, 27 Apr 2024 13:15:39 +0200 Subject: [PATCH] bump dt0 --- composer.json | 2 +- src/Caster/CollectionOfCaster.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index dc38cba..c9d924a 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ ], "require": { "php": "^8.1", - "fab2s/dt0": "v0.x-dev", + "fab2s/dt0": "dev-main", "illuminate/translation": "^10.0|^11.0", "illuminate/validation": "^10.0|^11.0" }, diff --git a/src/Caster/CollectionOfCaster.php b/src/Caster/CollectionOfCaster.php index d9d69c1..259be32 100644 --- a/src/Caster/CollectionOfCaster.php +++ b/src/Caster/CollectionOfCaster.php @@ -11,8 +11,8 @@ use fab2s\Dt0\Caster\ArrayType; use fab2s\Dt0\Caster\CasterInterface; +use fab2s\Dt0\Caster\ScalarCaster; use fab2s\Dt0\Caster\ScalarType; -use fab2s\Dt0\Caster\ScalarTypeCaster; use fab2s\Dt0\Dt0; use fab2s\Dt0\Exception\CasterException; use fab2s\Dt0\Property\Property; @@ -21,7 +21,7 @@ class CollectionOfCaster implements CasterInterface { public readonly ArrayType|ScalarType|string $logicalType; - protected ?ScalarTypeCaster $scalarTypeCaster; + protected ?ScalarCaster $scalarCaster; /** * @throws CasterException @@ -44,8 +44,8 @@ public function __construct( throw new CasterException('[' . Dt0::classBasename(static::class) . "] $type is not an ArrayType nor a ScalarType"); } - $this->logicalType = $logicalType; - $this->scalarTypeCaster = $this->logicalType instanceof ScalarType ? new ScalarTypeCaster($this->logicalType) : null; + $this->logicalType = $logicalType; + $this->scalarCaster = $this->logicalType instanceof ScalarType ? new ScalarCaster($this->logicalType) : null; } public function cast(mixed $value): ?Collection @@ -60,7 +60,7 @@ public function cast(mixed $value): ?Collection $result->push(match ($this->logicalType) { ArrayType::DT0 => $this->type::tryFrom($item), ArrayType::ENUM => Property::tryEnum($this->type, $item), - default => $this->scalarTypeCaster->cast($item), + default => $this->scalarCaster->cast($item), }); }