any() публичный статический Метод

Example: $array = array('a', true, 'c'); $any = Arrays::any($array, function ($element) { return is_bool($element); }); Result: true
public static any ( array $elements, callable $predicate ) : boolean
$elements array
$predicate callable
Результат boolean
Пример #1
0
 public function join()
 {
     $any = Arrays::any($this->_query->joinClauses, function (JoinClause $joinClause) {
         return Strings::equalsIgnoreCase($joinClause->type, 'RIGHT');
     });
     if ($any) {
         throw new BadMethodCallException('RIGHT JOIN is not supported in sqlite3');
     }
     return parent::join();
 }
Пример #2
0
 private static function _buildWhereKeyIn($column, array $array)
 {
     $useRestrictions = Arrays::any($array, Functions::isInstanceOf('\\Ouzo\\Restriction\\Restriction'));
     if ($useRestrictions) {
         return DialectUtil::joinClauses($array, 'OR', function (Restriction $restriction) use($column) {
             return $restriction->toSql($column);
         });
     }
     $in = implode(', ', array_fill(0, count($array), '?'));
     return $column . ' IN (' . $in . ')';
 }
Пример #3
0
 public function excludes()
 {
     $elements = func_get_args();
     $currentArray = $this->actual;
     $foundElement = '';
     $anyFound = Arrays::any($elements, function ($element) use($currentArray, &$foundElement) {
         $checkInArray = Arrays::contains($currentArray, $element);
         if ($checkInArray) {
             $foundElement = $element;
         }
         return $checkInArray;
     });
     AssertAdapter::assertFalse($anyFound, "Found element {$foundElement} in array {$this->actualString}");
     return $this;
 }
Пример #4
0
 private function isAlreadyAddedToFetch(RelationToFetch $relationToFetch)
 {
     return Arrays::any($this->_relationsToFetch, RelationToFetch::equalsPredicate($relationToFetch));
 }
Пример #5
0
 private static function whereClauseNeverSatisfied($whereClauses)
 {
     return Arrays::any($whereClauses, function (WhereClause $whereClause) {
         return $whereClause->isNeverSatisfied();
     });
 }
Пример #6
0
 /**
  * @test
  */
 public function shouldCheckIsAnyIsBool()
 {
     //given
     $array = array('a', true, 'c');
     //when
     $any = Arrays::any($array, function ($element) {
         return is_bool($element);
     });
     //then
     $this->assertTrue($any);
 }
Пример #7
0
 private static function existRouteRule($methods, $uri)
 {
     $routeKeys = Route::$routeKeys;
     return Arrays::any($methods, function ($method) use($routeKeys, $uri) {
         return Arrays::keyExists($routeKeys, $method . $uri);
     });
 }