public function setBaseClass($type)
    {
        if (!is_string($type) || empty($type)) {
            throw new InvalidArgumentException(
                'Class name or type must be a non-empty string.'
            );
        }

        $exists = (class_exists($type) || interface_exists($type));
        if ($exists) {
            $className = $type;
        } else {
            $className = $this->resolve($type);

            $exists = (class_exists($className) || interface_exists($className));
            if (!$exists) {
                throw new InvalidArgumentException(
                    sprintf('Can not set "%s" as base class: Invalid class or interface name.', $className)
                );
            }
        }

        $this->baseClass = $className;

        return $this;
    }