Download src/Affiliate/Domain/ValueObjects/Count.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 974 Bytes
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Affiliate/Domain/ValueObjects/Count.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Affiliate/Domain/ValueObjects/Count.php
-
curl -L -o Count.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Affiliate/Domain/ValueObjects/Count.php
974 Bytes
| declare(strict_types=1); | |
| namespace Affiliate\Domain\ValueObjects; | |
| use Doctrine\DBAL\Types\Types; | |
| use Doctrine\ORM\Mapping as ORM; | |
| use JsonSerializable; | |
| use Override; | |
| use Shared\Domain\Exceptions\InvalidValueException; | |
| #[ORM\Embeddable] | |
| class Count implements JsonSerializable | |
| { | |
| #[ORM\Column(name: "count", type: Types::INTEGER)] | |
| public readonly int $value; | |
| public function __construct(int $value) | |
| { | |
| $this->ensureValueIsValid($value); | |
| $this->value = $value; | |
| } | |
| public function jsonSerialize(): int | |
| { | |
| return $this->value; | |
| } | |
| /** | |
| * @throws InvalidValueException | |
| */ | |
| private function ensureValueIsValid(int $value): void | |
| { | |
| if ($value < 0) { | |
| throw new InvalidValueException(sprintf( | |
| '<%s> does not allow the value <%s>. Value must greater than 0.', | |
| static::class, | |
| $value | |
| )); | |
| } | |
| } | |
| } | |