Code Duplication    Length = 20-20 lines in 2 locations

Arr.php 2 locations

@@ 491-510 (lines=20) @@
488
    public static function initial(array $array, $callback, $default = null)
489
    {
490
        // When given a callable, keep counting as long as the callable returns a truthy value.
491
        if (is_callable($callback)) {
492
            $i = 0;
493
494
            foreach (array_reverse($array) as $key => $value) {
495
                if (!$callback($value, $key)) {
496
                    break;
497
                }
498
499
                $i++;
500
            }
501
502
            // If we didn't get at least a single truthy value, return the default.
503
            if ($i === 0) {
504
                return $default;
505
            }
506
507
            // Otherwise we're just gonna overwrite the $callback and proceed as if it were an integer in the
508
            // first place.
509
            $callback = $i;
510
        }
511
512
        // At this point we need a positive integer, 1 at minimum.
513
        return array_slice($array, 0, -(int) (!$callback ? 1 : abs($callback)));
@@ 808-827 (lines=20) @@
805
        }
806
807
        // With a callable given, keep counting as long as the callable returns a truthy value.
808
        if (is_callable($callback)) {
809
            $i = 0;
810
811
            foreach ($array as $key => $value) {
812
                if (!$callback($value, $key)) {
813
                    break;
814
                }
815
816
                $i++;
817
            }
818
819
            // If we didn't get at least a single truthy value, return the default.
820
            if ($i === 0) {
821
                return $default;
822
            }
823
824
            // Otherwise we're just gonna overwrite the $callback and proceed as if it were an integer in the
825
            // first place.
826
            $callback = $i;
827
        }
828
829
        // Return the final $callback elements.
830
        return array_slice($array, abs((int) $callback));