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