| Total Complexity | 6 | 
| Total Lines | 52 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 12 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php  | 
            ||
| 10 | class TaxNumberFormatter implements Formatter  | 
            ||
| 11 | { | 
            ||
| 12 | /**  | 
            ||
| 13 | * @param string|null $tax_number  | 
            ||
| 14 | * @param string|null $country  | 
            ||
| 15 | */  | 
            ||
| 16 | 15 | public function __construct(  | 
            |
| 17 | public ?string $tax_number = null,  | 
            ||
| 18 | public ?string $country = null  | 
            ||
| 19 |     ) { | 
            ||
| 20 | 15 |         $filteredTaxNumber = preg_replace_array('/[^\d\w]/', [], (string) $this->tax_number); | 
            |
| 21 | 15 | $this->tax_number = Str::upper($filteredTaxNumber);  | 
            |
| 22 | 15 | $this->country = Str::upper((string) $this->country);  | 
            |
| 23 | }  | 
            ||
| 24 | |||
| 25 | /**  | 
            ||
| 26 | * Format the Tax Number.  | 
            ||
| 27 | *  | 
            ||
| 28 | * @return string  | 
            ||
| 29 | */  | 
            ||
| 30 | 15 | public function format(): string  | 
            |
| 31 |     { | 
            ||
| 32 | 15 | return ! blank($this->country)  | 
            |
| 33 | 11 | ? $this->getFullTaxNumber()  | 
            |
| 34 | 15 | : (string) $this->tax_number;  | 
            |
| 35 | }  | 
            ||
| 36 | |||
| 37 | /**  | 
            ||
| 38 | * @return string  | 
            ||
| 39 | */  | 
            ||
| 40 | 11 | private function getPrefix(): string  | 
            |
| 41 |     { | 
            ||
| 42 | 11 | return (string) Str::of($this->tax_number)  | 
            |
| 43 | 11 | ->substr(0, 2)  | 
            |
| 44 | 11 | ->upper();  | 
            |
| 45 | }  | 
            ||
| 46 | |||
| 47 | /**  | 
            ||
| 48 | * @return string  | 
            ||
| 49 | */  | 
            ||
| 50 | 11 | private function getFullTaxNumber(): string  | 
            |
| 62 | }  | 
            ||
| 63 | }  | 
            ||
| 64 |