| Conditions | 3 |
| Paths | 3 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 29 | 8 | public function format(Collection $items): string |
|
| 30 | { |
||
| 31 | 8 | $tax_number = preg_replace( |
|
| 32 | 8 | '/[^\d\w]/', |
|
| 33 | 8 | '', |
|
| 34 | 8 | $items->get($this->key_number, '') |
|
| 35 | ); |
||
| 36 | |||
| 37 | 8 | if (empty($items->get($this->key_country))) { |
|
| 38 | 2 | return $tax_number; |
|
| 39 | } |
||
| 40 | |||
| 41 | 6 | $country = strtoupper($items->get($this->key_country)); |
|
| 42 | |||
| 43 | 6 | $prefix = strtoupper( |
|
| 44 | 6 | substr( |
|
| 45 | 6 | $tax_number, |
|
| 46 | 6 | 0, |
|
| 47 | 6 | strlen($country) |
|
| 48 | ) |
||
| 49 | ); |
||
| 50 | |||
| 51 | 6 | return $prefix === $country |
|
| 52 | 2 | ? $country . substr( |
|
| 53 | 2 | $tax_number, |
|
| 54 | 2 | strlen($country) |
|
| 55 | ) |
||
| 56 | 6 | : $country . $tax_number; |
|
| 57 | } |
||
| 59 |