public function setListener($listener = null)
    {
        if (null !== $listener && !is_object($listener) && !is_string($listener)) {
            throw new \InvalidArgumentException(sprintf(
                'Workflow state listener must be type of null, object or string, %s given.',
                gettype($listener)
            ));
        }

        if (null !== $listener && !is_subclass_of($listener, 'BackBee\Workflow\ListenerInterface')) {
            throw new \LogicException(sprintf(
                'Workflow state listener must implement %s.',
                'BackBee\Workflow\ListenerInterface'
            ));
        }

        $this->_listener = is_object($listener) ? get_class($listener) : $listener;
        $this->listenerInstance = null;

        return $this;
    }