protected static function __takeWhile(callable $predicate, array $list) : array
    {
        $result = [];

        foreach ($list as $item) {
            if ($predicate($item)) {
                $result[] = $item;
            } else {
                break;
            }
        }

        return $result;
    }
protected static function __takeWhile(callable $predicate, array $list) : array
    {
        $result = [];

        foreach ($list as $item) {
            if ($predicate($item)) {
                $result[] = $item;
            } else {
                break;
            }
        }

        return $result;
    }
protected static function __takeWhile ( callable $ predicate , array $ list ) : array { $ result = [ ] ; foreach ( $ list as $ item ) { if ( $ predicate ( $ item ) ) { $ result [ ] = $ item ; } else { break ; } } return $ result ; }
Take Elements with Predicate

Given some function that returns true or false, return the first elements of the array
that all pass the test, until the test fails.

@example
$greaterThanOne = function($n) { return $n > 1; };
Arrays::takeWhile($greaterThanOne, [5, 5, 5, 1, 5, 5]); // [5, 5, 5]

@type (a -> Bool) -> [a] -> [a]

@param  callable $predicate Function to use for testing each element
@param  array    $list      List to take elements from
@return array               First elements of list that all pass the $predicate
Take Elements with Predicate