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