Lines 100.00% 6 / 6
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 5 / 5 100.00% 1 / 1 2
 __toString 100.00% 1 / 1 100.00% 1 / 1 1
11final readonly class ActionName implements Stringable
12{
13    private const string PATTERN = '/\A([a-z0-9_]+)\.([a-z0-9_]+)\z/';
14
15    public string $value;
16
17    public string $domain;
18
19    public string $action;
20
21    /** @throws ActionCallException */
22    public function __construct(string $value)
23    {
24        if (preg_match(self::PATTERN, $value, $parts) !== 1) {
25            throw ActionCallException::createForReason(ActionCallError::ActionNameInvalid, action: $value);
26        }
27
28        $this->value = $value;
29        $this->domain = $parts[1];
30        $this->action = $parts[2];
31    }
32
33    public function __toString(): string
34    {
35        return $this->value;
36    }
37}