private static function getClassMethods($class) { $methods = $class->getMethods(); return Arrays::filter($methods, function (ReflectionMethod $method) { return !$method->isConstructor() && !$method->isStatic(); }); }
private function getMatchingStubbedCalls($methodCall) { $matching = Arrays::filter($this->_stubbed_calls, function ($stubbed_call) use($methodCall) { return $stubbed_call->matches($methodCall); }); return $matching; }
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; }
/** * @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); }
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; }
public function filter($function) { $this->_array = Arrays::filter($this->_array, $function); return $this; }
private function _removeMessages() { if (!$this->_keepMessage && Session::has('messages')) { $messages = Arrays::filter(Session::get('messages'), function (Notice $notice) { return !$notice->requestUrlMatches(); }); $this->saveMessagesWithEmptyCheck($messages); } }
/** * @return Parameter[]|array */ public function getNoHeaderParameters() { return Arrays::filter($this->parameters, function (Parameter $parameter) { return !$parameter->isHeader(); }); }
/** * Returns model object as a nicely formatted string. */ public function inspect() { return get_called_class() . Objects::toString(Arrays::filter($this->_attributes, Functions::notNull())); }
public static function getRoutesForController($controller) { return Arrays::filter(self::getRoutes(), function (RouteRule $route) use($controller) { return Strings::equalsIgnoreCase($route->getController(), $controller); }); }