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

@@ 494-513 (lines=20) @@
491
     *
492
     * @return mixed
493
     */
494
    protected function arrayItem(array $array, $key, $default = null)
495
    {
496
        if (is_null($key)) {
497
            return $array;
498
        }
499
500
        if (isset($array[$key])) {
501
            return $array[$key];
502
        }
503
504
        foreach (explode('.', $key) as $segment) {
505
            if (!is_array($array) || !array_key_exists($segment, $array)) {
506
                return $default;
507
            }
508
509
            $array = $array[$segment];
510
        }
511
512
        return $array;
513
    }
514
515
    /**
516
     * Put state to session storage and return it.