Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
16 / 16
CatalogFlow
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
16 / 16
 __construct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
 fromArray
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
5 / 5
 toArray
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 equals
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 __toString
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 catalogFlowId
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 version
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
<?php
declare(strict_types=1);
namespace App\Order\Domain\ValueObject;
use App\Shared\ValueObjectInterface;
use Assert\Assertion;
final class CatalogFlow implements ValueObjectInterface
{
    private CatalogFlowId $catalogFlowId;
    private int $version;
    private function __construct(
        CatalogFlowId $catalogFlowId,
        int $version
    ) {
        $this->catalogFlowId = $catalogFlowId;
        $this->version = $version;
    }
    public static function fromArray(array $data): self
    {
        Assertion::uuid($data['uuid']);
        Assertion::integer($data['version']);
        return new self(
            CatalogFlowId::fromString($data['uuid']),
            $data['version']
        );
    }
    public function toArray(): array
    {
        return [
            'uuid' => $this->catalogFlowId->toString(),
            'version' => $this->version,
        ];
    }
    public function equals(ValueObjectInterface $valueObject): bool
    {
        if (!$valueObject instanceof self) {
            return false;
        }
        return $this->toArray() === $valueObject->toArray();
    }
    public function __toString(): string
    {
        return (string) json_encode($this->toArray());
    }
    public function catalogFlowId(): CatalogFlowId
    {
        return $this->catalogFlowId;
    }
    public function version(): int
    {
        return $this->version;
    }
}