Lines 0.00% 0 / 5
Functions and Methods 0.00% 0 / 5
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
WorkerId 0.00% 0 / 5 0.00% 0 / 5 30 0.00% 0 / 1
 __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
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Model;
6
7use Stringable;
8
9final 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}