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;
    }
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;
    }
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 ; }
If a base class is set, then it must be ensured that the created objects
are `instanceof` this base class.

@param string $type The FQN of the class, or "type" of object, to set as base class.
@throws InvalidArgumentException If the class is not a string or is not an existing class / interface.
@return self
If a base class is set then it must be ensured that the created objects are instanceof this base class .