@param string $class

@throws \InvalidArgumentException
@return FunctionCompiler
513789
public function getFunctionCompiler($class)
    {
        if (!isset($this->functionCompilers[ $class ])) {
            $this->functionCompilers[ $class ] = new $class;
            if (!$this->functionCompilers[ $class ] instanceof FunctionCompiler) {
                throw new \InvalidArgumentException(
                    "Class {$class} is not an instance of FunctionCompiler"
                );
            }
        }

        return $this->functionCompilers[ $class ];
    }
541386
public function create(string $class) : BootstrapperInterface
    {
        if (!isset($this->instances[$class])) {
            $this->instances[$class] = new $class($this->container, $this->bootstrappers->getPaths());
        }

        return $this->instances[$class];
    }
1026718
public function bindInjector(string $class, $injector): Container
    {
        if (!is_string($injector)) {
            throw new \InvalidArgumentException('Injector can only be set as string binding');
        }

        $this->injectors[$class] = $injector;

        return $this;
    }
1016923
protected function getHelper($class) {
    if (!isset($this->helpers[$class])) {
      $qualified_class = '\DrupalCodeBuilder\Task\Generate\\' . $class;

      switch ($class) {
        case 'ComponentDataInfoGatherer':
          $helper = new $qualified_class($this->getHelper('ComponentClassHandler'));
          break;
        case 'ComponentCollector':
          $helper = new $qualified_class(
            $this->environment,
            $this->getHelper('ComponentClassHandler'),
            $this->getHelper('ComponentDataInfoGatherer')
          );
          break;
        default:
          $helper = new $qualified_class();
          break;
      }

      $this->helpers[$class] = $helper;
    }

    return $this->helpers[$class];
  }
150250
private static function reflect($class): \ReflectionClass
    {
        if (is_string($class) && (class_exists($class) || interface_exists($class) || trait_exists($class))) {
            return new \ReflectionClass($class);
        } elseif (is_object($class)) {
            return new \ReflectionObject($class);
        }

        throw new \InvalidArgumentException(
                'Given class must either be an existing class, interface or'
                . ' trait name or class instance, ' . \gettype($class)
                . ' with value "' . $class . '" given'
        );
    }
414472
public function build ($class)
    {
        $reflection = new \ReflectionClass($class);
        $parameters = [];

        if (!is_null($reflection->getConstructor())) {
            $parameters = $this->getParameters($reflection->getConstructor());
        }

        return new $class(...$parameters);
    }
1161722
public function pipe(callable $fn, $class = null)
    {
        $this->prepare();

        if (is_string($fn) && !is_null($class)) {
            $instance = new $class;

            $this->_map = call_user_func_array([$instance, $fn], [$this]);
            return $this;
        }

        $this->_map = $fn($this);
        return $this;
    }
728116
public function create(string $class, array $map = [], array $params = null)
    {
        try {
            return Builder::create($this, $class, $map, $params);
        } catch (\InvalidArgumentException $e) {
            throw new InvalidArgumentException($e->getMessage());
        }
    }
102045
public function load(string $class): self
    {
        $filename = $this->getFilename($class);
        if ($filename !== null) {
            (static function($__filename) {
                include_once $__filename;
            })($filename);
        }
        return $this;
    }
1057989
public static function instantiateClassByConstructor($class, $args)
    {
        switch (count($args)) {
            case 0:
                return new $class();
            case 1:
                return new $class($args[0]);
            case 2:
                return new $class($args[0], $args[1]);
            case 3:
                return new $class($args[0], $args[1], $args[2]);
            case 4:
                return new $class($args[0], $args[1], $args[2], $args[3]);
            default:
                $rClass = new \ReflectionClass($class);
                return $rClass->newInstanceArgs($args);
        }
    }
1129745
protected function getClassMetadata(string $class): ClassMetadata
    {
        $factory = $this->getDoctrineHelper()->getMetadataFactory();
        if (!$factory->hasMetadataFor($class)) {
            throw new \InvalidArgumentException(sprintf('No metadata found for class "%s"', $class));
        }
        
        return $factory->getMetadataFor($class);
    }
730373
public static function buildClass( $class, array $parameters = [] )
	{
		if ( !is_string( $class ) )
			throw new BindingException( "Class must be a string" );

		if ( static::building( $class ) )
			throw new BindingException( "The class [" . $class . "] is already being built." );

		static::$buildStack[] = $class;

		try
		{
			$reflector = new \ReflectionClass( $class );

			// If the type is not instantiable, the developer is attempting to resolve
			// an abstract type such as an Interface of Abstract Class and there is
			// no binding registered for the abstractions so we need to bail out.
			if ( !$reflector->isInstantiable() )
				throw new BindingException( "Target [$class] is not instantiable." );

			$constructor = $reflector->getConstructor();

			// If there are no constructors, that means there are no dependencies then
			// we can just resolve the instances of the objects right away.
			if ( is_null( $constructor ) )
				return new $class;

			$dependencies = $constructor->getParameters();

			// Once we have all the constructor's parameters we can create each of the
			// dependency instances and then use the reflection instances to make a
			// new instance of this class, injecting the created dependencies in.
			$parameters = static::keyParametersByArgument( $dependencies, $parameters );

			$instances = static::getDependencies( $dependencies, $parameters, $class );

			array_pop( static::$buildStack );

			/**/

			return $reflector->newInstanceArgs( $instances );
		}
		catch ( \ReflectionException $e )
		{
			array_pop( static::$buildStack );

			throw new BindingException( "Failed to build [$class]: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() );
		}
	}
157246
public function compile()
    {
        $indent    = '    ';
        $getters   = array();
        $instances = $this->dumper->getAllInjectedDefinitions();

        /* @var $instance GeneratorInstance */
        foreach ($instances as $name => $instance) {
            $constructor = $instance->getConstructor();
            $instantiatorParams = $this->buildParams($instance->getParams());

            if ('__construct' !== $constructor) {
                // Constructor callback
                if (is_callable($constructor)) {
                    $callback = $constructor;

                    if (is_array($callback)) {
                        $class = (is_object($callback[0])) ? get_class($callback[0]) : $callback[0];
                        $method = $callback[1];
                    } elseif (is_string($callback) && strpos($callback, '::') !== false) {
                        list($class, $method) = explode('::', $callback, 2);
                    }

                    $callback = var_export(array($class, $method), true);

                    if (count($instantiatorParams)) {
                        $creation = sprintf('$object = call_user_func(%s, %s);', $callback, implode(', ', $instantiatorParams));
                    } else {
                        $creation = sprintf('$object = call_user_func(%s);', $callback);
                    }
                } else if (is_string($constructor) && strpos($constructor, '->') !== false) {
                    list($class, $method) = explode('->', $constructor, 2);

                    if (!class_exists($class)) {
                        throw new InvalidArgumentException('No class found: ' . $class);
                    }

                    if (count($instantiatorParams)) {
                        $creation = sprintf(
                            '$object = $di->get(%s)->%s(%s);',
                            var_export($class, true),
                            $method,
                            implode(', ', $instantiatorParams)
                        );
                    } else {
                        $creation = sprintf('$object = $di->get(%s)->%s();', var_export($class, true), $method);
                    }
                } else {
                    throw new InvalidArgumentException('Invalid instantiator supplied for class: ' . $name);
                }
            } else {
                $className = '\\' . trim($this->reduceAlias($name), '\\');

                if (count($instantiatorParams)) {
                    $creation = sprintf('$object = new %s(%s);', $className, implode(', ', $instantiatorParams));
                } else {
                    $creation = sprintf('$object = new %s();', $className);
                }
            }


            // Create method call code
            if ($instance->isShared()) {
                $creation .= "\n\nif (\$isShared) {\n" . $indent
                    . '$di->instanceManager()->addSharedInstance($object, \'' . $instance->getName() . '\');'
                    . "\n}\n";
            }

            $methods = '';

            foreach ($instance->getMethods() as $methodData) {
                $methodName   = $methodData['method'];
                $methodParams = $methodData['params'];
                // Create method parameter representation
                $params = $this->buildParams($methodParams);

                if (count($params)) {
                    $methods .= sprintf("\$object->%s(%s);\n", $methodName, implode(', ', $params));
                }
            }

            // Start creating getter
            $getterBody = "function (\\Zend\\Di\\Di \$di, \$isShared) {\n";

            // Creation and method calls
            $getterBody .= $indent . str_replace("\n", "\n" . $indent, $creation) . "\n";
            $getterBody .= $indent . str_replace("\n", "\n" . $indent, $methods);

            // End getter body
            $getterBody .= "\n" . $indent . "return \$object;\n}";

            $getters[$name] = $getterBody;
        }

        $fileBody = "return array(\n";

        foreach ($getters as $name => $getterBody) {
            $fileBody .= $indent . var_export($name, true);
            $fileBody .= ' => ' . str_replace("\n", "\n" . $indent, $getterBody) . ",\n\n";
        }

        $fileBody .= ");\n";

        // Create PHP file code generation object
        $generator = $this->getFileGenerator();
        $generator->setBody($fileBody);

        return $generator;
    }
822924
protected function resolve( $class )
	{
		$instance = UniversalBuilder::resolveClass( $class );

		if ( isset( $this->command ) )
			$instance->setCommand( $this->command );

		return $instance;
	}
1268662
protected function getHelper($class) {
    if (!isset($this->helpers[$class])) {
      $qualified_class = '\DrupalCodeBuilder\Task\Collect\\' . $class;

      switch ($class) {
        case 'HooksCollector':
          $qualified_class .= '8';
          $helper = new $qualified_class($this->environment);
          break;
        case 'PluginTypesCollector':
          $helper = new $qualified_class(
            $this->environment,
            $this->getHelper('ContainerBuilderGetter'),
            $this->getHelper('MethodCollector'),
            $this->getHelper('CodeAnalyser')
          );
          break;
        case 'ServiceTagTypesCollector':
          $helper = new $qualified_class(
            $this->environment,
            $this->getHelper('ContainerBuilderGetter'),
            $this->getHelper('MethodCollector')
          );
          break;
        case 'ServicesCollector':
          $helper = new $qualified_class(
            $this->environment,
            $this->getHelper('ContainerBuilderGetter'),
            $this->getHelper('CodeAnalyser')
          );
          break;
        default:
          $helper = new $qualified_class($this->environment);
          break;
      }

      $this->helpers[$class] = $helper;
    }

    return $this->helpers[$class];
  }
1162203
public function addClass ($class)
    {
        $targetArray = &$this->customClasses;
        if (!is_array($class))
            $targetArray[] = $class;
        else
            $targetArray = array_merge($targetArray, $class);
        return $this;
    }
118864
protected function createType($typeClass)
    {
        if ($typeClass !== TreeType::class && !is_subclass_of($typeClass, TreeType::class)) {
            throw new \InvalidArgumentException("Class '$typeClass' must extends TreeType class.");
        }

        $type = new $typeClass();
        if (is_a($type, ContainerAwareInterface::class)) {
            $type->setContainer($this->container);
        }

        return $type;
    }