/**
  * @param string     $eventName
  * @param string|int $priority
  *
  * @return int
  * @throws \InvalidArgumentException
  */
 protected function getActualPriority(string $eventName, $priority) : int
 {
     if (is_int($priority)) {
         return $priority;
     }
     if (!in_array($priority, ['first', 'last'], true)) {
         $mess = 'Unknown priority was given only "first", "last", or integer may be used';
         throw new \InvalidArgumentException($mess);
     }
     $listenerM = parent::getActualPriority($eventName, $priority);
     if ($priority === 'first') {
         $serviceM = array_key_exists($eventName, $this->serviceListeners) ? max(array_keys($this->serviceListeners[$eventName])) + 1 : 1;
         return $listenerM > $serviceM ? $listenerM : $serviceM;
     }
     $serviceM = array_key_exists($eventName, $this->serviceListeners) ? min(array_keys($this->serviceListeners[$eventName])) - 1 : -1;
     return $listenerM < $serviceM ? $listenerM : $serviceM;
 }