@param string          $name
@param string|callable $packageClass

@return IPackage
@throws InvalidArgumentException
761055
private function loadPackageFromClass(string $name, $packageClass) : Package\IPackage
    {
        if (is_callable($packageClass)) {
            $package      = $packageClass($this, $name);
            $packageClass = is_scalar($package) ? gettype($package) : get_class($package);
        } else {
            $package = null;
        }

        if (!is_subclass_of($packageClass, IPackage::class, true)) {
            throw InvalidArgumentException::format(
                'Invalid package class defined within cms: expecting subclass of %s, %s given',
                IPackage::class, $packageClass
            );
        }

        /** @var IPackage $package */
        if (!$package) {
            $package = $this->container->get($packageClass);
        }

        if ($package->getName() !== $name) {
            throw InvalidArgumentException::format(
                'Invalid package class defined within package: defined package name \'%s\' does not match package name \'%s\' from instance of %s',
                $name, $package->getName(), get_class($package)
            );
        }

        return $package;
    }
247589
protected function ___classMocker_call($name, $arguments)
    {
        $this->allowPrivateScope();
        $result = $this->__call($name, $arguments);
        $this->disallowPrivateScope();

        return $result;
    }
796523
public function required($name, $class = null)
    {
        if (! isset($this->$name)) {
            throw new InvalidModuleException('Undefined module: ' . $name . ', required by ' . Utilities::getCaller());
        }
        if (isset($class) and !Utilities::isSubclassOf($this->$name, $class)) {
            throw new InvalidModuleException(
                'The module "' . $name . '" of type ' . get_class($this->$name)
                . ' was expected by ' . Utilities::getCaller()
                . ' to be of type ' . $class
            );
        }
    }
313493
public function registerCustomDoctrineType($class, $name, $type)
    {
        if (! $this->connection->isDoctrineAvailable()) {
            throw new RuntimeException(
                'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal).'
            );
        }

        if (! Type::hasType($name)) {
            Type::addType($name, $class);

            $this->connection
                ->getDoctrineSchemaManager()
                ->getDatabasePlatform()
                ->registerDoctrineTypeMapping($type, $name);
        }
    }
1005288
public function optional($name, $class)
    {
        if (isset($this->$name) and !Utilities::isSubclassOf($this->$name, $class)) {
            throw new InvalidModuleException(
                'The module "' . $name . '" of type ' . get_class($this->$name)
                . ' was expected by ' . Utilities::getCaller()
                . ' to be of type ' . $class
            );
        }
    }
388052
public function setConstraintClass($name, $class)
    {
        // Ensure class exists
        if (!class_exists($class)) {
            throw new InvalidArgumentException('Unknown constraint ' . $name);
        }
        // Ensure class is appropriate
        if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
            throw new InvalidArgumentException('Invalid class ' . $name);
        }
        $this->constraintMap[$name] = $class;

        return $this;
    }
662016
protected function decorate($packageName)
    {
        $results = $this->repository->findPackages($packageName);

        if (!count($results)) {
            throw new \InvalidArgumentException('Could not find package with specified name ' . $packageName);
        }

        $latest   = array_slice($results, 0, 1)[0];
        $versions = array_slice($results, 1);
        $package  = new VersionedPackage($latest, $versions);

        return $this->decorateWithPackagistStats($package);
    }
979213
public function setTraitClass($traitClass)
    {
        if ($this->isObjectNameValid($traitClass) !== true) {
            throw new InvalidArgumentException('The name of the trait to use is not valid.');
        }

        $this->traitClass = $traitClass;

        return $this;
    }
1196427
public function createChildFile($name)
    {
        if (
            strpos($name, '\\') !== false
            || strpos($name, '/') !== false
            || strpos($name, '..') !== false
        ) {
            throw new InvalidArgumentException("Wrong file name {$name}");
        }

        $class = $this->fileClass;

        return new $class($this->absolutePath . '/' . $name);
    }
542701
public function instanceApp(string $appClass): ApplicationInterface
    {
        return $this
            ->container
            ->getApplicationContainer()
            ->add($this->applicationLoader->instanceApp($appClass));
    }
1032739
public function addCustomField($name, $class)
    {
        if (!$this->hasCustomField($name)) {
            return $this->customTypes[$name] = $class;
        }

        throw new \InvalidArgumentException('Custom field ['.$name.'] already exists on this form object.');
    }
1147775
public Weld addPackage(boolean scanRecursively, Class<?> packageClass) {
        packages.add(new PackInfo(packageClass, scanRecursively));
        return this;
    }
1018390
public function createPackage($name, array $data = array())
    {
        if (isset($this->packages[strtolower($name)])) {
            throw new \InvalidArgumentException(sprintf('The package "%s" already exists.', $name));
        }

        return $this->packages[strtolower($name)] = new PackageNode($name, $data);
    }
1032082
public function mapLazyService(string $name, $class = null)
    {
        if (isset($this->services[$name]) && ! $this->allowOverride) {
            throw ContainerModificationsNotAllowedException::fromExistingService($name);
        }
        $this->lazyServicesClassMap[$name] = $class ?? $name;
        $this->lazyServicesDelegator = null;
    }
1272459
public function getDelegate($packageType)
    {
        if (!isset($this->_instances[$packageType]))
        {
            if (isset($this->_delegates[$packageType]))
            {
                $classname = $this->_delegates[$packageType];
                $instance  = new $classname($this->io, $this->composer, 'nooku-framework');

                $this->_instances[$packageType] = $instance;
            }
            else throw new \InvalidArgumentException('Unknown package type `'.$packageType.'`.');
        }

        return $this->_instances[$packageType];
    }
639763
protected function package($name)
    {
        $package = $this->obtainPackage($name);

        if ($package == -1) {
            return;
        }

        list($name, $providers, $aliases, $after) = array_fill(0, 4, null);
        extract($package, EXTR_IF_EXISTS);

        $this->requireComposerPackage($name);

        if ($this->setupLaravelConfigFile($providers, $aliases) == -1) {
            return -1;
        }

        $this->executeScriptAfterPackageInstallation($after);
    }
245185
public function setInvokableClass($name, $invokableClass, $shared = null)
    {
        $invokableClass = strtr($invokableClass, '.', '\\');
        return parent::setInvokableClass($name, $invokableClass, $shared);
    }