Create Roles Programmatically

Adding or Creating user roles Programmatically drupal 8

 

$role = \Drupal\user\Entity\Role::create(array('id' => 'roleidsimplemachinename', 'label' => 'Label to displayed in UI '));
$role->save();