original_string: public function addRoleByName(string $roleName)
      {
          if (!$this->user) {
              throw new UserRequiredException();
          }
  
          $this->compileUserRoles();
  
          if ($this->hasRoleWithName($roleName)) {
              return;
          }
  
          $role = $this->roleProvider->getRoleWithName($roleName);
  
          if (!$role) {
              throw new InvalidRoleException($roleName);
          }
  
          $this->user->addRole($role);
          $this->userRoles[] = $roleName;
          $this->userProvider->update($this->user);
      }
code: public function addRoleByName(string $roleName)
      {
          if (!$this->user) {
              throw new UserRequiredException();
          }
  
          $this->compileUserRoles();
  
          if ($this->hasRoleWithName($roleName)) {
              return;
          }
  
          $role = $this->roleProvider->getRoleWithName($roleName);
  
          if (!$role) {
              throw new InvalidRoleException($roleName);
          }
  
          $this->user->addRole($role);
          $this->userRoles[] = $roleName;
          $this->userProvider->update($this->user);
      }
code_tokens: public function addRoleByName ( string $ roleName ) { if ( ! $ this -> user ) { throw new UserRequiredException ( ) ; } $ this -> compileUserRoles ( ) ; if ( $ this -> hasRoleWithName ( $ roleName ) ) { return ; } $ role = $ this -> roleProvider -> getRoleWithName ( $ roleName ) ; if ( ! $ role ) { throw new InvalidRoleException ( $ roleName ) ; } $ this -> user -> addRole ( $ role ) ; $ this -> userRoles [ ] = $ roleName ; $ this -> userProvider -> update ( $ this -> user ) ; }
docstring: Add a role for the current User
  
  @param $roleName
  
  @throws InvalidRoleException
  @throws UserRequiredException
  @internal param $roleId
docstring_tokens: Add a role for the current User