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 Population
12{
13    #[ORM\Column(type: "integer")]
14    private int $population;
15
16    public function __construct(int $population)
17    {
18        if (!self::validate($population)) {
19            throw new InvalidPopulationException();
20        }
21        $this->population = $population;
22    }
23
24    public function __toString(): string
25    {
26        return strval($this->population);
27    }
28
29    public function equals(self $other): bool
30    {
31        return $this->population === $other->population;
32    }
33
34    private static function validate(int $population): bool
35    {
36        if ($population <= 0) {
37            return false;
38        }
39        return true;
40    }
41}