Lines
0.00%
0 / 5
Methods
0.00%
0 / 5
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| fromInt | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| equals | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| toProcessIdPrefix | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| __toString | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| 9 | final readonly class WorkerId implements Stringable | |
| 10 | { | |
| 11 | private const string PROCESS_ID_PREFIX = 'w'; | |
| 12 | ||
| 13 | public function __construct(public int $value) {} | |
| 14 | ||
| 15 | public static function fromInt(int $value): self | |
| 16 | { | |
| 17 | return new self($value); | |
| 18 | } | |
| 19 | ||
| 20 | public function equals(self $other): bool | |
| 21 | { | |
| 22 | return $this->value === $other->value; | |
| 23 | } | |
| 24 | ||
| 25 | public function toProcessIdPrefix(): string | |
| 26 | { | |
| 27 | return self::PROCESS_ID_PREFIX . $this->value; | |
| 28 | } | |
| 29 | ||
| 30 | public function __toString(): string | |
| 31 | { | |
| 32 | return (string) $this->value; | |
| 33 | } | |
| 34 | } |