| Conditions | 5 |
| Paths | 6 |
| Total Lines | 35 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 5 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 30 | 5 | public static function transform( Pay_Address $address ) { |
|
| 31 | 5 | $country = $address->get_country(); |
|
| 32 | |||
| 33 | 5 | if ( null === $country ) { |
|
| 34 | 1 | return null; |
|
| 35 | } |
||
| 36 | |||
| 37 | 4 | $country_code = $country->get_code(); |
|
| 38 | |||
| 39 | 4 | if ( null === $country_code ) { |
|
| 40 | 1 | return null; |
|
| 41 | } |
||
| 42 | |||
| 43 | 3 | $state_or_province = null; |
|
| 44 | |||
| 45 | 3 | $region = $address->get_region(); |
|
| 46 | |||
| 47 | 3 | if ( null !== $region ) { |
|
| 48 | 1 | $state_or_province = $region->get_code(); |
|
| 49 | } |
||
| 50 | |||
| 51 | try { |
||
| 52 | 3 | $address = new Address( |
|
| 53 | 3 | $country_code, |
|
| 54 | 3 | $address->get_street_name(), |
|
| 55 | 3 | (string) $address->get_house_number(), |
|
| 56 | 3 | $address->get_postal_code(), |
|
| 57 | 3 | $address->get_city(), |
|
| 58 | $state_or_province |
||
| 59 | ); |
||
| 60 | 1 | } catch ( InvalidArgumentException $exception ) { |
|
| 61 | 1 | return null; |
|
| 62 | } |
||
| 63 | |||
| 64 | 2 | return $address; |
|
| 65 | } |
||
| 67 |