| @@ 202-211 (lines=10) @@ | ||
| 199 | * @param array $object |
|
| 200 | * @return mixed |
|
| 201 | */ |
|
| 202 | function get() { |
|
| 203 | static $get = false; |
|
| 204 | $get = $get ?: curry(function($name, $object){ |
|
| 205 | $object = attributes($object); |
|
| 206 | return has($name, $object) |
|
| 207 | ? $object[$name] |
|
| 208 | : null; |
|
| 209 | }); |
|
| 210 | return _apply($get, func_get_args()); |
|
| 211 | } |
|
| 212 | ||
| 213 | /** |
|
| 214 | * Gets a value from an array/object using a path of keys/attributes. |
|
| @@ 234-244 (lines=11) @@ | ||
| 231 | * @param mixed $object |
|
| 232 | * @return mixed |
|
| 233 | */ |
|
| 234 | function getPath() { |
|
| 235 | static $getPath = false; |
|
| 236 | $getPath = $getPath ?: curry(function($path, $object){ |
|
| 237 | return reduce(function($result, $name) { |
|
| 238 | if ($result !== null) |
|
| 239 | $result = get($name, $result); |
|
| 240 | return $result; |
|
| 241 | }, $object, $path); |
|
| 242 | }); |
|
| 243 | return _apply($getPath, func_get_args()); |
|
| 244 | } |
|
| 245 | ||
| 246 | /** |
|
| 247 | * Returns a new array or object with the value of a key or a public attribute set |
|