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

@@ 532-551 (lines=20) @@
529
     *
530
     * @return mixed
531
     */
532
    protected function arrayItem(array $array, $key, $default = null)
533
    {
534
        if (is_null($key)) {
535
            return $array;
536
        }
537
538
        if (isset($array[$key])) {
539
            return $array[$key];
540
        }
541
542
        foreach (explode('.', $key) as $segment) {
543
            if (!is_array($array) || !array_key_exists($segment, $array)) {
544
                return $default;
545
            }
546
547
            $array = $array[$segment];
548
        }
549
550
        return $array;
551
    }
552
553
    /**
554
     * Put state to session storage and return it.