| Total Complexity | 12 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Utils { |
||
| 6 | |||
| 7 | public static function EnsureArray($arr, $kfield = null) |
||
| 8 | { |
||
| 9 | if (is_array($arr)) { |
||
| 10 | return $arr; |
||
| 11 | } |
||
| 12 | $result = []; |
||
| 13 | foreach ($arr as $k => $v){ |
||
| 14 | $key = $k; |
||
| 15 | if ($kfield!==null) { |
||
| 16 | if (is_array($v) && isset($v[$kfield])) $key = $v[$kfield]; |
||
| 17 | elseif (is_object($v) && isset($v->$kfield)) $key = $v->$kfield; |
||
| 18 | } |
||
| 19 | $result[$key] = $v; |
||
| 20 | } |
||
| 21 | return $result; |
||
| 22 | } |
||
| 23 | |||
| 24 | public static function extractField($arr,$field) |
||
| 31 | } |
||
| 32 | |||
| 34 |