| 1 | <?php |
||
| 5 | trait ArrayGetterTrait |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Fetch a value from an array by key, or return |
||
| 9 | * a default if the key is not set. |
||
| 10 | * |
||
| 11 | * Analogous to python's `dict.get(key, default=None)` |
||
| 12 | * |
||
| 13 | * @param mixed[] $arr the array to be queried |
||
| 14 | * @param (int|string) $key the key to look up |
||
| 15 | * @param mixed $default the default return value |
||
| 16 | * |
||
| 17 | * @return mixed |
||
| 18 | */ |
||
| 19 | 279 | public function arrGet($arr, $key, $default = null) |
|
| 23 | } |
||
| 24 |