$handler->handleCompleteTask() * - \My\App\DoThingCommand => $handler->handleDoThing() */ class HandleClassNameWithoutSuffixInflector extends HandleClassNameInflector { /** * @var string */ private $suffix; /** * @var int */ private $suffixLength; /** * @param string $suffix The string to remove from end of each class name */ public function __construct($suffix = 'Command') { $this->suffix = $suffix; $this->suffixLength = strlen($suffix); } /** * @param object $command * @param object $commandHandler * @return string */ public function inflect($command, $commandHandler) { $methodName = parent::inflect($command, $commandHandler); if (substr($methodName, $this->suffixLength * -1) !== $this->suffix) { return $methodName; } return substr($methodName, 0, strlen($methodName) - $this->suffixLength); } }