本文整理汇总了PHP中Ouzo\Utilities\Arrays::firstOrNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::firstOrNull方法的具体用法?PHP Arrays::firstOrNull怎么用?PHP Arrays::firstOrNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ouzo\Utilities\Arrays
的用法示例。
在下文中一共展示了Arrays::firstOrNull方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: matches
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: firstOr
public function firstOr($default)
{
return Arrays::firstOrNull($this->_array) ?: $default;
}
示例3: fromTokens
/**
* @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: fetch
/**
* @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: getRawController
public function getRawController()
{
$path = $this->_pathProvider->getPath();
$pathElements = $this->_parsePath($path);
return Arrays::firstOrNull($pathElements);
}
示例6: read_kept
public function read_kept()
{
$this->layout->renderAjax(Arrays::firstOrNull(Session::get('messages') ?: array()));
$this->layout->unsetLayout();
}
示例7: delete
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: shouldReturnNullIfNotFoundFirstElement
/**
* @test
*/
public function shouldReturnNullIfNotFoundFirstElement()
{
//given
$array = array();
//when
$return = Arrays::firstOrNull($array);
//then
$this->assertNull($return);
}
示例9: extractValue
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;
}