public function detectCurrentStateName($subject) { if ($subject instanceof StatefulInterface) { return $subject->getCurrentStateName(); } else { throw new \InvalidArgumentException('Subject has to implement the StatefulInterface!'); } }