| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 190 | public function validate(AccountNumber $number): ResultInterface |
|
| 31 | { |
||
| 32 | 190 | $len = strlen($number->getSerialNumber()); |
|
| 33 | |||
| 34 | 190 | if ($len < $this->min) { |
|
| 35 | 45 | return new Failure( |
|
| 36 | 45 | "Invalid serial length $len, must be at least {$this->min}" |
|
| 37 | ); |
||
| 38 | } |
||
| 39 | |||
| 40 | 182 | if ($len > $this->max) { |
|
| 41 | 130 | return new Failure( |
|
| 42 | 130 | "Invalid serial length $len, must not be longer than {$this->max}" |
|
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | 178 | return new Success("Valid serial length $len"); |
|
| 47 | } |
||
| 48 | } |
||
| 49 |