Skip to content

Commit

Permalink
bump dt0
Browse files Browse the repository at this point in the history
  • Loading branch information
fab2s committed Apr 27, 2024
1 parent a43e567 commit b58f187
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
10 changes: 5 additions & 5 deletions src/Caster/CollectionOfCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,7 +21,7 @@
class CollectionOfCaster implements CasterInterface
{
public readonly ArrayType|ScalarType|string $logicalType;
protected ?ScalarTypeCaster $scalarTypeCaster;
protected ?ScalarCaster $scalarCaster;

/**
* @throws CasterException
Expand All @@ -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
Expand All @@ -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),
});
}

Expand Down

0 comments on commit b58f187

Please sign in to comment.