| 1 | <?php |
||
| 5 | class Helpers |
||
| 6 | { |
||
| 7 | public static function extractNestedDataFromArray($args = []) |
||
| 8 | { |
||
| 9 | if (count($args) < 2) { |
||
| 10 | return self::returnEmptyStringOrFirstArgument($args); |
||
| 11 | } |
||
| 12 | $key = array_pop($args); |
||
| 13 | $data = self::returnFirstArgumentOrNestedData($args); |
||
| 14 | return self::accessArrayOrObject($key, $data); |
||
| 15 | } |
||
| 16 | |||
| 17 | protected static function returnEmptyStringOrFirstArgument($args = []) |
||
| 18 | { |
||
| 19 | if (count($args) === 0) { |
||
| 20 | return ''; |
||
| 21 | } |
||
| 22 | if (count($args) === 1) { |
||
| 23 | return $args[0]; |
||
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | protected static function returnFirstArgumentOrNestedData($args = []) |
||
| 35 | |||
| 36 | protected static function accessArrayOrObject($key, $data) |
||
| 48 | } |
||
| 49 |