Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | 2 | public function asStr(): string |
|
20 | { |
||
21 | 2 | $countryCode = substr($this->userId, 0, 2); |
|
22 | 2 | if (preg_match('/^[A-Z]{2}$/', $countryCode) !== 1) { |
|
23 | 1 | throw new Exception( |
|
24 | 1 | sprintf( |
|
25 | 1 | 'Invalid country code prefix in userId. Must be two-letter ISO country code. Actual: %s', |
|
26 | 1 | $countryCode |
|
27 | ) |
||
28 | ); |
||
29 | } |
||
30 | |||
31 | 1 | return $this->userId; |
|
32 | } |
||
39 |