Getting the current user role in code is quite easy, here's the snippet.
$roles = \Drupal::currentUser()->getRoles(); if(in_array($roles, 'editor')) { // Do something if user has role editor }