name file | size | edit | permission | action |
---|---|---|---|---|
.env | 2733 KB | December 22 2024 06:20:07 | 0644 | |
404.html | 58370 KB | November 20 2024 15:32:22 | 0644 | |
502.html | 58368 KB | November 20 2024 15:32:22 | 0644 | |
Modules | - | December 11 2024 21:02:56 | 0755 | |
README.md | 4158 KB | February 14 2023 12:31:56 | 0644 | |
app | - | December 11 2024 17:57:48 | 0755 | |
artisan | 1686 KB | February 14 2023 12:31:56 | 0644 | |
bootstrap | - | December 11 2024 20:23:36 | 0755 | |
composer.json | 3761 KB | December 11 2024 22:15:00 | 0644 | |
composer.lock | 512048 KB | December 11 2024 22:13:28 | 0644 | |
config | - | June 15 2025 02:09:36 | 0755 | |
database | - | December 05 2024 20:18:12 | 0755 | |
dfsdf dfds fd fds findex.html | 1420 KB | November 20 2024 15:32:24 | 0644 | |
error_log | 13857878 KB | July 18 2025 15:46:12 | 0644 | |
firoz | - | December 23 2024 13:24:46 | 0755 | |
index.php | 1667 KB | December 14 2024 05:20:36 | 0644 | |
lang | - | December 11 2024 21:02:48 | 0755 | |
modules_statuses.json | 472 KB | November 20 2024 15:32:24 | 0644 | |
mpos | - | March 31 2025 02:36:31 | 0755 | |
package.json | 226 KB | February 14 2023 12:31:56 | 0644 | |
phpunit.xml | 1146 KB | February 14 2023 12:31:56 | 0644 | |
public | - | March 31 2025 02:36:31 | 0755 | |
resources | - | December 11 2024 21:10:22 | 0755 | |
routes | - | June 15 2025 02:09:31 | 0755 | |
storage | - | December 11 2024 21:12:44 | 0755 | |
tests | - | December 05 2024 20:18:12 | 0755 | |
vendor | - | December 11 2024 22:13:30 | 0755 | |
vite.config.js | 263 KB | February 14 2023 12:31:56 | 0644 |
*/ abstract class AbstractUid implements \JsonSerializable, \Stringable { /** * The identifier in its canonic representation. */ protected $uid; /** * Whether the passed value is valid for the constructor of the current class. */ abstract public static function isValid(string $uid): bool; /** * Creates an AbstractUid from an identifier represented in any of the supported formats. * * @throws \InvalidArgumentException When the passed value is not valid */ abstract public static function fromString(string $uid): static; /** * @throws \InvalidArgumentException When the passed value is not valid */ public static function fromBinary(string $uid): static { if (16 !== \strlen($uid)) { throw new \InvalidArgumentException('Invalid binary uid provided.'); } return static::fromString($uid); } /** * @throws \InvalidArgumentException When the passed value is not valid */ public static function fromBase58(string $uid): static { if (22 !== \strlen($uid)) { throw new \InvalidArgumentException('Invalid base-58 uid provided.'); } return static::fromString($uid); } /** * @throws \InvalidArgumentException When the passed value is not valid */ public static function fromBase32(string $uid): static { if (26 !== \strlen($uid)) { throw new \InvalidArgumentException('Invalid base-32 uid provided.'); } return static::fromString($uid); } /** * @param string $uid A valid RFC 9562/4122 uid * * @throws \InvalidArgumentException When the passed value is not valid */ public static function fromRfc4122(string $uid): static { if (36 !== \strlen($uid)) { throw new \InvalidArgumentException('Invalid RFC4122 uid provided.'); } return static::fromString($uid); } /** * Returns the identifier as a raw binary string. */ abstract public function toBinary(): string; /** * Returns the identifier as a base58 case sensitive string. * * @example 2AifFTC3zXgZzK5fPrrprL (len=22) */ public function toBase58(): string { return strtr(sprintf('%022s', BinaryUtil::toBase($this->toBinary(), BinaryUtil::BASE58)), '0', '1'); } /** * Returns the identifier as a base32 case insensitive string. * * @see https://tools.ietf.org/html/rfc4648#section-6 * * @example 09EJ0S614A9FXVG9C5537Q9ZE1 (len=26) */ public function toBase32(): string { $uid = bin2hex($this->toBinary()); $uid = sprintf('%02s%04s%04s%04s%04s%04s%04s', base_convert(substr($uid, 0, 2), 16, 32), base_convert(substr($uid, 2, 5), 16, 32), base_convert(substr($uid, 7, 5), 16, 32), base_convert(substr($uid, 12, 5), 16, 32), base_convert(substr($uid, 17, 5), 16, 32), base_convert(substr($uid, 22, 5), 16, 32), base_convert(substr($uid, 27, 5), 16, 32) ); return strtr($uid, 'abcdefghijklmnopqrstuv', 'ABCDEFGHJKMNPQRSTVWXYZ'); } /** * Returns the identifier as a RFC 9562/4122 case insensitive string. * * @see https://datatracker.ietf.org/doc/html/rfc9562/#section-4 * * @example 09748193-048a-4bfb-b825-8528cf74fdc1 (len=36) */ public function toRfc4122(): string { // don't use uuid_unparse(), it's slower $uuid = bin2hex($this->toBinary()); $uuid = substr_replace($uuid, '-', 8, 0); $uuid = substr_replace($uuid, '-', 13, 0); $uuid = substr_replace($uuid, '-', 18, 0); return substr_replace($uuid, '-', 23, 0); } /** * Returns the identifier as a prefixed hexadecimal case insensitive string. * * @example 0x09748193048a4bfbb8258528cf74fdc1 (len=34) */ public function toHex(): string { return '0x'.bin2hex($this->toBinary()); } /** * Returns whether the argument is an AbstractUid and contains the same value as the current instance. */ public function equals(mixed $other): bool { if (!$other instanceof self) { return false; } return $this->uid === $other->uid; } public function compare(self $other): int { return (\strlen($this->uid) - \strlen($other->uid)) ?: ($this->uid <=> $other->uid); } public function __toString(): string { return $this->uid; } public function jsonSerialize(): string { return $this->uid; } }