Code Duplication    Length = 38-38 lines in 2 locations

src/helpers.php 2 locations

@@ 389-426 (lines=38) @@
386
    }
387
}
388
389
if ( ! function_exists('array_set'))
390
{
391
    /**
392
     * Set an array item to a given value using "dot" notation.
393
     *
394
     * If no key is given to the method, the entire array will be replaced.
395
     *
396
     * @param  array   $array
397
     * @param  string  $key
398
     * @param  mixed   $value
399
     * @return array
400
     */
401
    function array_set(&$array, $key, $value)
402
    {
403
        if (is_null($key)) return $array = $value;
404
405
        $keys = explode('.', $key);
406
407
        while (count($keys) > 1)
408
        {
409
            $key = array_shift($keys);
410
411
            // If the key doesn't exist at this depth, we will just create an empty array
412
            // to hold the next value, allowing us to create the arrays to hold final
413
            // values at the correct depth. Then we'll keep digging into the array.
414
            if ( ! isset($array[$key]) || ! is_array($array[$key]))
415
            {
416
                $array[$key] = array();
417
            }
418
419
            $array =& $array[$key];
420
        }
421
422
        $array[array_shift($keys)] = $value;
423
424
        return $array;
425
    }
426
}
427
428
if ( ! function_exists('array_where'))
429
{
@@ 977-1014 (lines=38) @@
974
    }
975
}
976
977
if ( ! function_exists('set'))
978
{
979
    /**
980
     * Set an array item to a given value using "dot" notation.
981
     *
982
     * If no key is given to the method, the entire array will be replaced.
983
     *
984
     * @param  array   $array
985
     * @param  string  $key
986
     * @param  mixed   $value
987
     * @return array
988
     */
989
    function set(&$array, $key, $value)
990
    {
991
        if (is_null($key)) return $array = $value;
992
993
        $keys = explode('.', $key);
994
995
        while (count($keys) > 1)
996
        {
997
            $key = array_shift($keys);
998
999
            // If the key doesn't exist at this depth, we will just create an empty array
1000
            // to hold the next value, allowing us to create the arrays to hold final
1001
            // values at the correct depth. Then we'll keep digging into the array.
1002
            if ( ! isset($array[$key]) || ! is_array($array[$key]))
1003
            {
1004
                $array[$key] = array();
1005
            }
1006
1007
            $array =& $array[$key];
1008
        }
1009
1010
        $array[array_shift($keys)] = $value;
1011
1012
        return $array;
1013
    }
1014
}
1015
1016
if ( ! function_exists('dot'))
1017
{