| Conditions | 4 |
| Paths | 6 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4.0218 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | 7 | public function match($address) |
|
| 34 | { |
||
| 35 | 7 | $address = is_a($address, Address::class) === true ? $address : new Address($address); |
|
| 36 | 7 | $zip3 = $this->storage->zip3($address); |
|
|
|
|||
| 37 | |||
| 38 | 7 | if (empty($zip3) === true) { |
|
| 39 | return; |
||
| 40 | } |
||
| 41 | |||
| 42 | 7 | $rule = $this->storage->rules($zip3)->find(function ($rule) use ($address) { |
|
| 43 | 7 | return $rule->match($address); |
|
| 44 | 7 | }); |
|
| 45 | |||
| 46 | 7 | return is_null($rule) === false ? $rule->zip5() : $zip3; |
|
| 47 | } |
||
| 48 | } |
||
| 49 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.