Lines 100.00% 3 / 3
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
PopulationFilter 100.00% 3 / 3 100.00% 2 / 2 5 100.00% 1 / 1
 __construct 100.00% 2 / 2 100.00% 1 / 1 2
 validate 100.00% 1 / 1 100.00% 1 / 1 3
1<?php
2
3declare(strict_types=1);
4
5namespace Districts\Editor\Domain\DistrictFilter;
6
7use InvalidArgumentException;
8
9readonly class PopulationFilter extends Filter
10{
11    public function __construct(
12        public int $begin,
13        public int $end,
14    ) {
15        if (!self::validate($begin, $end)) {
16            throw new InvalidArgumentException();
17        }
18    }
19
20    private static function validate(int $begin, int $end): bool
21    {
22        return $begin >= 0 && $end >= 0 && $end >= $begin;
23    }
24}