Lines 100.00% 8 / 8
Methods 100.00% 4 / 4
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 3 / 3 100.00% 1 / 1 2
 __toString 100.00% 1 / 1 100.00% 1 / 1 1
 equals 100.00% 1 / 1 100.00% 1 / 1 1
 validate 100.00% 3 / 3 100.00% 1 / 1 2
11readonly class Name
12{
13    #[ORM\Column(type: "string", options: ["collation" => "utf8_polish_ci"])]
14    private string $name;
15
16    public function __construct(string $name)
17    {
18        if (!self::validate($name)) {
19            throw new InvalidNameException();
20        }
21        $this->name = $name;
22    }
23
24    public function __toString(): string
25    {
26        return $this->name;
27    }
28
29    public function equals(self $other): bool
30    {
31        return $this->name === $other->name;
32    }
33
34    private static function validate(string $name): bool
35    {
36        if ($name === "") {
37            return false;
38        }
39        return true;
40    }
41}