Code Duplication    Length = 14-14 lines in 3 locations

system/libraries/URI.php 3 locations

@@ 39-52 (lines=14) @@
36
     * @param   mixed           default value returned if segment does not exist
37
     * @return  string
38
     */
39
    public function segment($index = 1, $default = false)
40
    {
41
        if (is_string($index)) {
42
            if (($key = array_search($index, URI::$segments)) === false) {
43
                return $default;
44
            }
45
46
            $index = $key + 2;
47
        }
48
49
        $index = (int) $index - 1;
50
51
        return isset(URI::$segments[$index]) ? URI::$segments[$index] : $default;
52
    }
53
54
    /**
55
     * Retrieve a specific routed URI segment.
@@ 61-74 (lines=14) @@
58
     * @param   mixed           default value returned if segment does not exist
59
     * @return  string
60
     */
61
    public function rsegment($index = 1, $default = false)
62
    {
63
        if (is_string($index)) {
64
            if (($key = array_search($index, URI::$rsegments)) === false) {
65
                return $default;
66
            }
67
68
            $index = $key + 2;
69
        }
70
71
        $index = (int) $index - 1;
72
73
        return isset(URI::$rsegments[$index]) ? URI::$rsegments[$index] : $default;
74
    }
75
76
    /**
77
     * Retrieve a specific URI argument.
@@ 84-97 (lines=14) @@
81
     * @param   mixed           default value returned if segment does not exist
82
     * @return  string
83
     */
84
    public function argument($index = 1, $default = false)
85
    {
86
        if (is_string($index)) {
87
            if (($key = array_search($index, URI::$arguments)) === false) {
88
                return $default;
89
            }
90
91
            $index = $key + 2;
92
        }
93
94
        $index = (int) $index - 1;
95
96
        return isset(URI::$arguments[$index]) ? URI::$arguments[$index] : $default;
97
    }
98
99
    /**
100
     * Returns an array containing all the URI segments.