Lines 60.00% 3 / 5
Methods 33.33% 1 / 3
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 3 / 3 100.00% 1 / 1 2
 equals 0.00% 0 / 1 0.00% 0 / 1 2
 __toString 0.00% 0 / 1 0.00% 0 / 1 2
11final readonly class CommitId implements Stringable
12{
13    private const string HASH_PATTERN = '/\A(?:[0-9a-f]{40}|[0-9a-f]{64})\z/';
14
15    public string $value;
16
17    /** @throws DeployException */
18    public function __construct(string $value)
19    {
20        if (preg_match(self::HASH_PATTERN, $value) !== 1) {
21            throw DeployException::createForReason(DeployError::CommitIdInvalid, value: $value);
22        }
23
24        $this->value = $value;
25    }
26
27    public function equals(self $other): bool
28    {
29        return $this->value === $other->value;
30    }
31
32    public function __toString(): string
33    {
34        return $this->value;
35    }
36}