| Conditions | 3 |
| Paths | 3 |
| Total Lines | 43 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 12 | public static function transform( $locale ) { |
|
| 32 | 12 | if ( ! is_string( $locale ) ) { |
|
|
|
|||
| 33 | 1 | return null; |
|
| 34 | } |
||
| 35 | |||
| 36 | // Supported locales. |
||
| 37 | $supported = array( |
||
| 38 | 11 | Locales::EN_US, |
|
| 39 | Locales::NL_NL, |
||
| 40 | Locales::NL_BE, |
||
| 41 | Locales::FR_FR, |
||
| 42 | Locales::FR_BE, |
||
| 43 | Locales::DE_DE, |
||
| 44 | Locales::DE_AT, |
||
| 45 | Locales::DE_CH, |
||
| 46 | Locales::ES_ES, |
||
| 47 | Locales::CA_ES, |
||
| 48 | Locales::PT_PT, |
||
| 49 | Locales::IT_IT, |
||
| 50 | Locales::NB_NO, |
||
| 51 | Locales::SV_SE, |
||
| 52 | Locales::FI_FI, |
||
| 53 | Locales::DA_DK, |
||
| 54 | Locales::IS_IS, |
||
| 55 | Locales::HU_HU, |
||
| 56 | Locales::PL_PL, |
||
| 57 | Locales::LV_LV, |
||
| 58 | Locales::LT_LT, |
||
| 59 | ); |
||
| 60 | |||
| 61 | // Lower case. |
||
| 62 | 11 | $locale = strtolower( $locale ); |
|
| 63 | |||
| 64 | // Is supported? |
||
| 65 | 11 | $supported_lowercase = array_map( 'strtolower', $supported ); |
|
| 66 | |||
| 67 | 11 | $search = array_search( $locale, $supported_lowercase, true ); |
|
| 68 | |||
| 69 | 11 | if ( false !== $search ) { |
|
| 70 | 3 | return $supported[ $search ]; |
|
| 71 | } |
||
| 72 | |||
| 73 | 8 | return null; |
|
| 74 | } |
||
| 76 |