diff --git a/src/ArchitectureBundle/Domain/ValueObject/CompositeAggregateIdTrait.php b/src/ArchitectureBundle/Domain/ValueObject/CompositeAggregateIdTrait.php index 607ed9d..23d6800 100644 --- a/src/ArchitectureBundle/Domain/ValueObject/CompositeAggregateIdTrait.php +++ b/src/ArchitectureBundle/Domain/ValueObject/CompositeAggregateIdTrait.php @@ -8,6 +8,7 @@ use SixtyEightPublishers\ArchitectureBundle\Domain\Exception\InvalidNativeValueTypeException; use SixtyEightPublishers\ArchitectureBundle\Domain\Exception\Typehint; use function array_key_exists; +use function array_map; use function count; use function implode; @@ -155,7 +156,13 @@ public function getValues(): array public function toString(): string { - return implode('/', $this->values); + return implode( + separator: '/', + array: array_map( + callback: \strval(...), + array: $this->values, + ), + ); } public function __toString(): string diff --git a/src/ArchitectureBundle/Domain/ValueObject/FloatValueTrait.php b/src/ArchitectureBundle/Domain/ValueObject/FloatValueTrait.php index 867f65e..af51ebf 100644 --- a/src/ArchitectureBundle/Domain/ValueObject/FloatValueTrait.php +++ b/src/ArchitectureBundle/Domain/ValueObject/FloatValueTrait.php @@ -45,6 +45,16 @@ public function equals(ValueObjectInterface $object): bool return $object instanceof static && $object->toNative() === $this->toNative(); } + public function toString(): string + { + return (string) $this->toNative(); + } + + public function __toString(): string + { + return $this->toString(); + } + protected function validate(): void { } diff --git a/src/ArchitectureBundle/Domain/ValueObject/IntegerValueTrait.php b/src/ArchitectureBundle/Domain/ValueObject/IntegerValueTrait.php index 36af5e8..fb18372 100644 --- a/src/ArchitectureBundle/Domain/ValueObject/IntegerValueTrait.php +++ b/src/ArchitectureBundle/Domain/ValueObject/IntegerValueTrait.php @@ -45,6 +45,16 @@ public function equals(ValueObjectInterface $object): bool return $object instanceof static && $object->toNative() === $this->toNative(); } + public function toString(): string + { + return (string) $this->toNative(); + } + + public function __toString(): string + { + return $this->toString(); + } + protected function validate(): void { } diff --git a/src/ArchitectureBundle/Domain/ValueObject/StringValueTrait.php b/src/ArchitectureBundle/Domain/ValueObject/StringValueTrait.php index b5e2949..18fc1ea 100644 --- a/src/ArchitectureBundle/Domain/ValueObject/StringValueTrait.php +++ b/src/ArchitectureBundle/Domain/ValueObject/StringValueTrait.php @@ -45,6 +45,16 @@ public function equals(ValueObjectInterface $object): bool return $object instanceof static && $object->toNative() === $this->toNative(); } + public function toString(): string + { + return $this->toNative(); + } + + public function __toString(): string + { + return $this->toString(); + } + protected function validate(): void { }