src/BaseClipboard.php
protected function countMatchingRoles($authority, $roles)
    {
        $lookups = $this->getRolesLookup($authority);

        return count(array_filter($roles, function ($role) use ($lookups) {
            switch (true) {
                case is_string($role):
                    return $lookups['names']->has($role);
                case is_numeric($role):
                    return $lookups['ids']->has($role);
                case $role instanceof Model:
                    return $lookups['ids']->has($role->getKey());
            }

            throw new InvalidArgumentException('Invalid model identifier');
        }));
    }
protected function countMatchingRoles($authority, $roles)
    {
        $lookups = $this->getRolesLookup($authority);

        return count(array_filter($roles, function ($role) use ($lookups) {
            switch (true) {
                case is_string($role):
                    return $lookups['names']->has($role);
                case is_numeric($role):
                    return $lookups['ids']->has($role);
                case $role instanceof Model:
                    return $lookups['ids']->has($role->getKey());
            }

            throw new InvalidArgumentException('Invalid model identifier');
        }));
    }
protected function countMatchingRoles ( $ authority , $ roles ) { $ lookups = $ this -> getRolesLookup ( $ authority ) ; return count ( array_filter ( $ roles , function ( $ role ) use ( $ lookups ) { switch ( true ) { case is_string ( $ role ) : return $ lookups [ 'names' ] -> has ( $ role ) ; case is_numeric ( $ role ) : return $ lookups [ 'ids' ] -> has ( $ role ) ; case $ role instanceof Model : return $ lookups [ 'ids' ] -> has ( $ role -> getKey ( ) ) ; } throw new InvalidArgumentException ( 'Invalid model identifier' ) ; } ) ) ; }
Count the authority's roles matching the given roles.

@param  \Illuminate\Database\Eloquent\Model  $authority
@param  array|string  $roles
@return int
Count the authority s roles matching the given roles .