本文整理汇总了PHP中Ouzo\Utilities\Arrays::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::filter方法的具体用法?PHP Arrays::filter怎么用?PHP Arrays::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ouzo\Utilities\Arrays
的用法示例。
在下文中一共展示了Arrays::filter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClassMethods
private static function getClassMethods($class)
{
$methods = $class->getMethods();
return Arrays::filter($methods, function (ReflectionMethod $method) {
return !$method->isConstructor() && !$method->isStatic();
});
}
示例2: getMatchingStubbedCalls
private function getMatchingStubbedCalls($methodCall)
{
$matching = Arrays::filter($this->_stubbed_calls, function ($stubbed_call) use($methodCall) {
return $stubbed_call->matches($methodCall);
});
return $matching;
}
示例3: _getColumnsWithoutPrimary
private function _getColumnsWithoutPrimary(Dialect $dialect)
{
$primaryKeyName = $this->primaryKeyName;
$columns = $dialect->columns();
if ($primaryKeyName != 'id') {
return Arrays::filter($columns, function (DatabaseColumn $column) use($primaryKeyName) {
return $column->name != $primaryKeyName;
});
}
return $columns;
}
示例4: shouldFilterValues
/**
* @test
*/
public function shouldFilterValues()
{
//given
$array = array(1, 2, 3, 4);
//when
$result = Arrays::filter($array, function ($value) {
return $value > 2;
});
//then
$this->assertEquals(array(2 => 3, 3 => 4), $result);
}
示例5: process
public function process()
{
$post = $this->post;
$filterLogin = Arrays::filter($this->getElements(), function ($element) use($post) {
if ($element->user_name == $post->user_auth->user_name && $element->password == $post->user_auth->password) {
return $element;
}
return null;
});
if (!$filterLogin) {
$response = new stdClass();
$response->name = 'Invalid Login';
$response->number = '10';
$response->description = 'Login attempt failed please check the username and password';
$this->response = $response;
} else {
$user = Arrays::first($filterLogin);
$response = new stdClass();
$response->id = $user->id;
$this->response = $response;
}
return $this;
}
示例6: filter
public function filter($function)
{
$this->_array = Arrays::filter($this->_array, $function);
return $this;
}
示例7: _removeMessages
private function _removeMessages()
{
if (!$this->_keepMessage && Session::has('messages')) {
$messages = Arrays::filter(Session::get('messages'), function (Notice $notice) {
return !$notice->requestUrlMatches();
});
$this->saveMessagesWithEmptyCheck($messages);
}
}
示例8: getNoHeaderParameters
/**
* @return Parameter[]|array
*/
public function getNoHeaderParameters()
{
return Arrays::filter($this->parameters, function (Parameter $parameter) {
return !$parameter->isHeader();
});
}
示例9: inspect
/**
* Returns model object as a nicely formatted string.
*/
public function inspect()
{
return get_called_class() . Objects::toString(Arrays::filter($this->_attributes, Functions::notNull()));
}
示例10: getRoutesForController
public static function getRoutesForController($controller)
{
return Arrays::filter(self::getRoutes(), function (RouteRule $route) use($controller) {
return Strings::equalsIgnoreCase($route->getController(), $controller);
});
}