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 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| AreaFilter | 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 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Districts\Editor\Domain\DistrictFilter; | |
| 6 | ||
| 7 | use InvalidArgumentException; | |
| 8 | ||
| 9 | readonly class AreaFilter extends Filter | |
| 10 | { | |
| 11 | public function __construct( | |
| 12 | public float $begin, | |
| 13 | public float $end, | |
| 14 | ) { | |
| 15 | if (!self::validate($begin, $end)) { | |
| 16 | throw new InvalidArgumentException(); | |
| 17 | } | |
| 18 | } | |
| 19 | ||
| 20 | private static function validate(float $begin, float $end): bool | |
| 21 | { | |
| 22 | return $begin >= 0 && $end >= 0 && $end >= $begin; | |
| 23 | } | |
| 24 | } |