| @@ 45-63 (lines=19) @@ | ||
| 42 | * |
|
| 43 | * @return mixed |
|
| 44 | */ |
|
| 45 | public function get($key, $default = null) |
|
| 46 | { |
|
| 47 | $config = $this->config; |
|
| 48 | ||
| 49 | if (is_null($key)) { |
|
| 50 | return $config; |
|
| 51 | } |
|
| 52 | if (isset($config[$key])) { |
|
| 53 | return $config[$key]; |
|
| 54 | } |
|
| 55 | foreach (explode('.', $key) as $segment) { |
|
| 56 | if (!is_array($config) || !array_key_exists($segment, $config)) { |
|
| 57 | return $default; |
|
| 58 | } |
|
| 59 | $config = $config[$segment]; |
|
| 60 | } |
|
| 61 | ||
| 62 | return $config; |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Set an array item to a given value using "dot" notation. |
|
| @@ 513-532 (lines=20) @@ | ||
| 510 | * |
|
| 511 | * @return mixed |
|
| 512 | */ |
|
| 513 | protected function arrayItem(array $array, $key, $default = null) |
|
| 514 | { |
|
| 515 | if (is_null($key)) { |
|
| 516 | return $array; |
|
| 517 | } |
|
| 518 | ||
| 519 | if (isset($array[$key])) { |
|
| 520 | return $array[$key]; |
|
| 521 | } |
|
| 522 | ||
| 523 | foreach (explode('.', $key) as $segment) { |
|
| 524 | if (!is_array($array) || !array_key_exists($segment, $array)) { |
|
| 525 | return $default; |
|
| 526 | } |
|
| 527 | ||
| 528 | $array = $array[$segment]; |
|
| 529 | } |
|
| 530 | ||
| 531 | return $array; |
|
| 532 | } |
|
| 533 | ||
| 534 | /** |
|
| 535 | * Put state to session storage and return it. |
|