Download src/Affiliate/Domain/ValueObjects/Code.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 704 Bytes
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Affiliate/Domain/ValueObjects/Code.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Affiliate/Domain/ValueObjects/Code.php
-
curl -L -o Code.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Affiliate/Domain/ValueObjects/Code.php
704 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 Random\RandomException; | |
| #[ORM\Embeddable] | |
| class Code implements JsonSerializable | |
| { | |
| #[ORM\Column(type: Types::STRING, name: "code", unique: true)] | |
| public readonly string $value; | |
| /** | |
| * @throws RandomException | |
| */ | |
| public function __construct(?string $value = null) | |
| { | |
| if (is_null($value)) { | |
| $value = bin2hex(random_bytes(6)); | |
| } | |
| $this->value = $value; | |
| } | |
| public function jsonSerialize(): string | |
| { | |
| return $this->value; | |
| } | |
| } | |