public function hasRole($role)
    {
        $roles = $this->getRoles();
        /** @var Role $roleObject */
        foreach ($roles as $roleObject) {
            if ($roleObject->getRole() == strtoupper($role)) {
                return true;
            }
        }
        return false;
    }
public function hasRole($role)
    {
        $roles = $this->getRoles();
        /** @var Role $roleObject */
        foreach ($roles as $roleObject) {
            if ($roleObject->getRole() == strtoupper($role)) {
                return true;
            }
        }
        return false;
    }
public function hasRole ( $ role ) { $ roles = $ this -> getRoles ( ) ; /** @var Role $roleObject */ foreach ( $ roles as $ roleObject ) { if ( $ roleObject -> getRole ( ) == strtoupper ( $ role ) ) { return true ; } } return false ; }
Never use this to check if this user has access to anything!

Use the SecurityContext, or an implementation of AccessDecisionManager
instead, e.g.

$securityContext->isGranted('ROLE_USER');

@param string $role

@return boolean
Never use this to check if this user has access to anything!