/** @test */ public function method_all() { $arr = [3, 4, 5, 6]; $this->assertTrue(Fn\all($arr, Fn\moreThanOrEqualTo(3))); $this->assertFalse(Fn\all($arr, Fn\even())); $this->assertFalse(Fn\all($arr, Fn\odd())); }
/** @return boolean */ public function isGranted(RouteMatch $routeMatch) { // No guards --> not granted by default if (!count($this->guards)) { return false; } return Fn\all($this->guards, function (GuardInterface $guard) use($routeMatch) { return $guard->isGranted($routeMatch); }); }
public function vote(TokenInterface $token, $object, array $attributes) { $isSupported = $this->supportsClass(get_class($object)) && Fn\all($attributes, [$this, 'supportsAttribute']) && call_user_func($this->_supportsResource, $object); if (!$isSupported) { return self::ACCESS_ABSTAIN; } $user = $token->getUser(); $limit = call_user_func($this->_getLimit, $user); $count = call_user_func($this->_getCount, $user); if ($limit === -1) { return self::ACCESS_GRANTED; } return $count >= $limit ? self::ACCESS_DENIED : self::ACCESS_GRANTED; }
/** * Can this provider authenticate the current request? * * Should return true if the means for authentication are available, * even if the user cannot be authenticate * (eg. a username/password are provided, but they do not match a real user) * * @return boolean */ public function canAuthenticate() { return Fn\all(['client_id', 'client_secret'], function ($k) { return $this->param($k) !== null; }); }