public function resolveStateMachineName($arg)
    {
        if (is_string($arg) && empty(trim($arg))) {
            throw new RuntimeError('State machine name must be a non-empty string.');
        }

        if (is_string($arg)) {
            return $arg;
        }

        $default_suffix = $this->config->get('state_machine_name_suffix', 'default_workflow');

        if ($arg instanceof AggregateRootTypeInterface || $arg instanceof ProjectionTypeInterface) {
            return $arg->getPrefix() . '.' . $default_suffix;
        } elseif ($arg instanceof AggregateRootInterface || $arg instanceof ProjectionInterface) {
            return $arg->getType()->getPrefix() . '.' . $default_suffix;
        } elseif (is_object($arg) && is_callable($arg, 'getStateMachineName')) {
            return $arg->getStateMachineName();
        } elseif (is_object($arg) && is_callable($arg, '__toString')) {
            return (string)$arg;
        }

        throw new RuntimeError('Could not resolve a state machine name for given argument.');
    }