protected function checkUserHasRole($user, string $role): bool
    {
        if (! in_array($role, $user->roles, true)) {
            $message = sprintf(
                '[W804] User with login: %s exists, but role %s is not in the list of applied roles: %s',
                $user->user_login,
                $role,
                $user->roles
            );
            throw new \UnexpectedValueException($message);
        }

        return true;
    }
protected function checkUserHasRole($user, string $role): bool
    {
        if (! in_array($role, $user->roles, true)) {
            $message = sprintf(
                '[W804] User with login: %s exists, but role %s is not in the list of applied roles: %s',
                $user->user_login,
                $role,
                $user->roles
            );
            throw new \UnexpectedValueException($message);
        }

        return true;
    }
protected function checkUserHasRole ( $ user , string $ role ) : bool { if ( ! in_array ( $ role , $ user -> roles , true ) ) { $ message = sprintf ( '[W804] User with login: %s exists, but role %s is not in the list of applied roles: %s' , $ user -> user_login , $ role , $ user -> roles ) ; throw new \ UnexpectedValueException ( $ message ) ; } return true ; }
Checks to see if the user has an assigned role or not.

@param object $user
@param string $role

@throws \UnexpectedValueException

@return boolean $retval True if the role does apply to the user.
Checks to see if the user has an assigned role or not .