本文整理匯總了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;
}