Code Duplication    Length = 19-20 lines in 3 locations

src/helpers.php 3 locations

@@ 168-187 (lines=20) @@
165
    }
166
}
167
168
if ( ! function_exists('array_first'))
169
{
170
    /**
171
     * Return the first element in an array passing a given truth test.
172
     *
173
     * @param  array     $array
174
     * @param  \Closure  $callback
175
     * @param  mixed     $default
176
     * @return mixed
177
     */
178
    function array_first($array, $callback, $default = null)
179
    {
180
        foreach ($array as $key => $value)
181
        {
182
            if (call_user_func($callback, $key, $value)) return $value;
183
        }
184
185
        return value($default);
186
    }
187
}
188
189
if ( ! function_exists('array_last'))
190
{
@@ 369-387 (lines=19) @@
366
    }
367
}
368
369
if ( ! function_exists('array_pull'))
370
{
371
    /**
372
     * Get a value from the array, and remove it.
373
     *
374
     * @param  array   $array
375
     * @param  string  $key
376
     * @param  mixed   $default
377
     * @return mixed
378
     */
379
    function array_pull(&$array, $key, $default = null)
380
    {
381
        $value = get($array, $key, $default);
382
383
        forget($array, $key);
384
385
        return $value;
386
    }
387
}
388
389
if ( ! function_exists('array_set'))
390
{
@@ 1045-1064 (lines=20) @@
1042
    }
1043
}
1044
1045
if ( ! function_exists('first'))
1046
{
1047
    /**
1048
     * Return the first element in an array passing a given truth test.
1049
     *
1050
     * @param  array     $array
1051
     * @param  \Closure  $callback
1052
     * @param  mixed     $default
1053
     * @return mixed
1054
     */
1055
    function first($array, $callback, $default = null)
1056
    {
1057
        foreach ($array as $key => $value)
1058
        {
1059
            if (call_user_func($callback, $key, $value)) return $value;
1060
        }
1061
1062
        return value($default);
1063
    }
1064
}
1065
1066
if ( ! function_exists('forget'))
1067
{