Lines
90.00%
9 / 10
Methods
83.33%
5 / 6
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| describeKind | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| [Stewart\Contracts\Registry\RegistryId] __construct | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Contracts\Registry\RegistryId] tryFromString | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Contracts\Registry\RegistryId] fromStringOrId | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Contracts\Registry\RegistryId] equals | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | ||
| [Stewart\Contracts\Registry\RegistryId] __toString | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 7 | final readonly class DeviceId extends RegistryId | |
| 8 | { | |
| 9 | protected function describeKind(): string | |
| 10 | { | |
| 11 | return 'Device'; | |
| 12 | } | |
| 13 | } |
Inherited from Stewart\Contracts\Registry\RegistryId
| 16 | final public function __construct(string $value) | |
| 17 | { | |
| 18 | if ($value === '') { | |
| 19 | throw IdentifierException::createForReason(IdentifierError::RegistryIdEmpty, kind: $this->describeKind()); | |
| 20 | } | |
| 21 | ||
| 22 | $this->value = $value; | |
| 23 | } |
| 25 | public static function tryFromString(string $value): ?static | |
| 26 | { | |
| 27 | try { | |
| 28 | return new static($value); | |
| 29 | } catch (IdentifierException) { | |
| 30 | return null; | |
| 31 | } | |
| 32 | } |
| 35 | public static function fromStringOrId(self|string $id): static | |
| 36 | { | |
| 37 | return $id instanceof static ? $id : new static((string) $id); | |
| 38 | } |
| 40 | public function equals(self $other): bool | |
| 41 | { | |
| 42 | return $other::class === static::class && $other->value === $this->value; | |
| 43 | } |
| 45 | public function __toString(): string | |
| 46 | { | |
| 47 | return $this->value; | |
| 48 | } |