Add or replace a wrapper with a fully qualified class name.

@throws \RuntimeException

@param  string $name
@param  string $class

@return $this
427430
public function registerWrapper($name, $class)
    {
        if (!is_subclass_of($class, WrapperInterface::class)) {
            throw new \RuntimeException(sprintf(
                'Wrapper class "%s" must be implement ' . WrapperInterface::class,
                $class
            ));
        }
        $this->wrappers[$name] = $class;

        return $this;
    }
429053
public function instantiate($class,array $params=array()){
		if(!class_exists($class,true)){
			throw new \RuntimeException('given class '.$class.' not exists');
		}		
		$params = array_values($params);
		switch(count($params)){
			case 0: return new $class(); break;
			case 1: return new $class($params[0]); break;
			case 2: return new $class($params[0],$params[1]); break;
			case 3: return new $class($params[0],$params[1],$params[2]); break;
			case 4: return new $class($params[0],$params[1],$params[2],$params[3]); break;
			case 5: return new $class($params[0],$params[1],$params[2],$params[3],$params[4]); break;
			case 6: return new $class($params[0],$params[1],$params[2],$params[3],$params[4],$params[5]); break;
			case 7: return new $class($params[0],$params[1],$params[2],$params[3],$params[4],$params[5],$params[6]); break;
			case 8: return new $class($params[0],$params[1],$params[2],$params[3],$params[4],$params[5],$params[6],$params[7]); break;
			default:
				$relection = new \ReflectionObject($class);
				return $reflection->newInstanceArgs($params);
		}
	}
656937
public function setClass($class = '')
    {
        if (is_string($class) && (empty($class) === true || Format::isClass($class) === true)) {
            $class = trim($class);
            $this->class = $class;
        } else {
            $msg = "The 'class' argument must be a valid class name, '" . $class . "' given";
            throw new InvalidArgumentException($msg);
        }
    }
157123
public static function create($class, $name)
    {
        $actor = Pool::getInstance()->get($class);
        $actor->initialization($name);
        return $actor;
    }
1332143
private function getManagerForClass($class)
    {
        $tries = [];

        foreach ($this->managers as $manager) {
            if ($manager->supportsClass($class)) {
                return $manager;
            }

            $tries[] = get_class($manager);
        }

        throw new \RuntimeException(
            sprintf(
                'Class "%s" is not supported by any UserManager. Tried "%s".',
                $class,
                implode('", "', $tries)
            )
        );
    }
1024496
public static function registerType($name, $class, $phpTypeName)
    {
        if (isset(static::$typesMap[$name])) {
            throw new BadArgumentException('Cannot register new type with name ":name" because it already registered', [
                'name' => $name,
            ]);
        }
        
        static::overrideType($name, $class, $phpTypeName);
    }
630724
public function register($alias, $class)
	{
		$alias = strtolower($alias);

		if (array_key_exists($alias, $this->instances))
		{
			throw new \RuntimeException('You cannot register a provider when an instance of that class has already been created.');
		}

		$this->services[$alias] = $class;

		return $this;
	}
220237
public function addCustomNodeClass(string $name, string $class): self{
        if(!is_subclass_of($class, NodeInterface::class)){
            throw new \InvalidArgumentException();
        }

        $this->customNodes[$name]   = $class;

        return $this;
    }
1056459
public static function create($class, EntityManager $entityManager)
    {
        $rc = new \ReflectionClass($class);
        $interface = 'Blast\CoreBundle\CodeGenerator\CodeGeneratorInterface';
        if (!$rc->implementsInterface($interface)) {
            throw new \RuntimeException("Class $class should implement $interface");
        }
        $codeGenerator = new $class();
        $codeGenerator::setEntityManager($entityManager);

        return $codeGenerator;
    }
546161
public function addClass($name)
    {
        foreach ($this as $node) {
            if ($node instanceof \DOMElement) {
                /** @var \DOMElement $node */
                $classes = preg_split('/\s+/s', $node->getAttribute('class'));
                $found = false;
                $count = count($classes);
                for ($i = 0; $i < $count; $i++) {
                    if ($classes[$i] == $name) {
                        $found = true;
                    }
                }
                if (!$found) {
                    $classes[] = $name;
                    $node->setAttribute('class', trim(join(' ', $classes)));
                }
            }
        }
        return $this;
    }
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.');
    }
1043488
public function disable($name = null)
	{
		// Check if it exists. if not, bail out
		if ( ! $this->field($name))
		{
			throw new \RuntimeException('Field "'.$name.'" does not exist in this Fieldset.');
		}

		isset($this->disabled[$name]) or $this->disabled[$name] = $name;

		return $this;
	}
1292611
public function addHelper($name, $helper)
    {
        if ($this->mustache !== null) {
            throw new RuntimeException(
                'Can not add helper to Mustache engine: the engine has already been initialized.'
            );
        }

        $this->helpers[$name] = $helper;

        return $this;
    }
173956
public function addDataSource($name, AbstractDataSource $dataSource)
    {
        if ($this->hasDataSource($name)) {
            throw new \RuntimeException(sprintf('A previous data source exists with the same name: "%s".', $name));
        }

        $this->dataSources[$name] = $dataSource;
    }
1311595
public static function bind($name, $class=null)
    {
        if (is_array($name)) {
            self::$bind=array_merge(self::$bind, $name);
        } else {
            self::$bind[$name]=$class;
        }
    }
403884
private function setUp($class, Run $run)
    {
        if (!$class) {
            $run->writeOutput("Missing `class` parameter on {$this->jobModel->id} job")
                ->setResult(Run::RESULT_FAILED);

            return false;
        }

        if (!class_exists($class)) {
            $run->writeOutput("$class does not exist")
                ->setResult(Run::RESULT_FAILED);

            return false;
        }

        $job = new $class();

        // inject the DI container if needed
        if (method_exists($job, 'setApp')) {
            $job->setApp($this->jobModel->getApp());
        }

        return $job;
    }
110043
public function addFunction($name, $function)
    {
        if ($this->initialized) {
            throw new RuntimeException(sprintf('Unable to add function "%s" as they have already been initialized.', $name));
        }

        $this->functions[$name] = $function;
    }