Code Duplication    Length = 19-20 lines in 2 locations

src/Config.php 1 location

@@ 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.

src/Providers/AbstractProvider.php 1 location

@@ 463-482 (lines=20) @@
460
     *
461
     * @return mixed
462
     */
463
    protected function arrayItem(array $array, $key, $default = null)
464
    {
465
        if (is_null($key)) {
466
            return $array;
467
        }
468
469
        if (isset($array[$key])) {
470
            return $array[$key];
471
        }
472
473
        foreach (explode('.', $key) as $segment) {
474
            if (!is_array($array) || !array_key_exists($segment, $array)) {
475
                return $default;
476
            }
477
478
            $array = $array[$segment];
479
        }
480
481
        return $array;
482
    }
483
484
    /**
485
     * Put state to session storage and return it.