| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class cfg_utils |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Force array |
||
| 16 | * |
||
| 17 | * @param mixed $items |
||
| 18 | * @return array |
||
| 19 | */ |
||
| 20 | public static function ensure_array($items) |
||
| 21 | { |
||
| 22 | return is_array($items) ? $items : explode(',', $items); |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Force multi dimensional array |
||
| 27 | * |
||
| 28 | * @param mixed $options |
||
| 29 | * @param string $css_class |
||
| 30 | * @return array |
||
| 31 | */ |
||
| 32 | public static function ensure_multi_array($options, &$css_class) |
||
| 33 | { |
||
| 34 | $test = current(cfg_utils::ensure_array($options)); |
||
| 35 | if (!is_array($test)) |
||
| 36 | { |
||
| 37 | $css_class = ''; |
||
| 38 | $options = array($options); |
||
| 39 | } |
||
| 40 | |||
| 41 | return array_map('array_filter', $options); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param string $needle |
||
| 46 | * @param array $haystack |
||
| 47 | * @param string $type selected|checked |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | public static function get_selected_option($needle, array $haystack, $type = 'selected') |
||
| 53 | } |
||
| 54 | } |
||
| 55 |