Code Duplication    Length = 7-7 lines in 2 locations

src/list.php 2 locations

@@ 130-136 (lines=7) @@
127
 * @param  array|string $list
128
 * @return mixed
129
 */
130
function head($list) {
131
    if(is_string($list))
132
        return substr($list, 0, 1);
133
    return (count($list) > 0)
134
        ? $list[0]
135
        : null;
136
}
137
138
/**
139
 * Returns the last item of the given array or string.
@@ 152-158 (lines=7) @@
149
 * @param  array|string $list
150
 * @return mixed
151
 */
152
function last($list) {
153
    if(is_string($list))
154
        return substr($list, -1);
155
    return (count($list) > 0)
156
        ? $list[count($list) - 1]
157
        : null;
158
}
159
160
/**
161
 * Returns all but the last element of the given array or string.