Whether a user has a certain role.
@todo in Drupal 11, add method to Drupal\Core\Session\AccountInterface.
string $rid: The role ID to check.
bool Returns TRUE if the user has the role, otherwise FALSE.
https://www.drupal.org/node/3228209
public function hasRole(string $rid) : bool { return in_array($rid, $this->getRoles(), TRUE); }