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

Example: $array = array(); $return = Arrays::firstOrNull($array); Result: null
public static firstOrNull ( array $elements ) : mixed | null
$elements array
Результат mixed | null
Пример #1
0
 public function matches(MethodCall $methodCall)
 {
     if ($methodCall->name != $this->name) {
         return false;
     }
     if (Arrays::firstOrNull($this->arguments) instanceof AnyArgumentList) {
         return true;
     }
     if (count($methodCall->arguments) != count($this->arguments)) {
         return false;
     }
     foreach ($this->arguments as $i => $arg) {
         if (!$this->argMatches($arg, $methodCall->arguments[$i])) {
             return false;
         }
     }
     return true;
 }
Пример #2
0
 public function firstOr($default)
 {
     return Arrays::firstOrNull($this->_array) ?: $default;
 }
Пример #3
0
 /**
  * @param TokenObject[] $tokens
  * @param boolean $header
  * @return Parameter
  */
 public static function fromTokens($tokens, $header = false)
 {
     $parser = new Parser($tokens);
     return new Parameter(Arrays::firstOrNull($parser->S()), $header);
 }
Пример #4
0
 /**
  * @return Model|array
  */
 public function fetch()
 {
     $result = QueryExecutor::prepare($this->_db, $this->_query)->fetch();
     if (!$result) {
         return null;
     }
     return !$this->_selectModel ? $result : Arrays::firstOrNull($this->_processResults(array($result)));
 }
Пример #5
0
 public function getRawController()
 {
     $path = $this->_pathProvider->getPath();
     $pathElements = $this->_parsePath($path);
     return Arrays::firstOrNull($pathElements);
 }
Пример #6
0
 public function read_kept()
 {
     $this->layout->renderAjax(Arrays::firstOrNull(Session::get('messages') ?: array()));
     $this->layout->unsetLayout();
 }
Пример #7
0
 public function delete()
 {
     $attributes = Arrays::map($this->whereClauses, Functions::extract()->getParams());
     $queryInsert = new QueryInsert(Arrays::firstOrNull($attributes));
     $id = $queryInsert->into($this->module->getModuleName());
     return !is_null($id);
 }
Пример #8
0
 /**
  * @test
  */
 public function shouldReturnNullIfNotFoundFirstElement()
 {
     //given
     $array = array();
     //when
     $return = Arrays::firstOrNull($array);
     //then
     $this->assertNull($return);
 }
Пример #9
0
 public function extractValue($values)
 {
     if (!$this->collection) {
         if (count($values) > 1) {
             throw new DbException("Expected one result for {$this->name}");
         }
         return Arrays::firstOrNull($values);
     }
     return $values;
 }