Add static $factory for $key.

@param string $key
@param string $factory
@return StaticFactoryResolver
@throws InvalidStaticFactory
184054
public function addStaticFactory(string $key, string $factory): StaticFactoryResolver
    {
        if (is_subclass_of($factory, StaticFactoryInterface::class, true) === false) {
            throw new InvalidStaticFactory($factory);
        }

        $this->factories[$key] = $factory;

        return $this;
    }
681018
static function factory()
    {
        if ( self::$factory === false )
        {
            self::$factory = true;
            self::instance()->readINISettings();
            eZImageAnalyzer::readAnalyzerSettingsFromINI();
        }
        return self::instance();
    }
810452
public function addStorageFactory(StorageFactoryInterface $factory)
    {
        $factoryName = $factory->getName();
        if (empty($factoryName)) {
            throw new InvalidArgumentException(sprintf('The storage factory %s has empty name', get_class($factory)));
        }
        if (array_key_exists($factoryName, $this->storagesFactories)) {
            throw new InvalidArgumentException(sprintf('The storage factory with such name %s already registered', $factoryName));
        }

        $this->storagesFactories[$factoryName] = $factory;
    }
1128905
public function withRuleFactory(string $name, callable $factory): ValidatorFactory
    {
        $factories = array_merge($this->factories, [$name => $factory]);

        return new ValidatorFactory($this->translator, $factories);
    }
150710
private function factory($name)
    {
        if ($this->factoryMuffin->isPendingOrSaved($this->model)) {
            return $this->factoryMuffin->create($name);
        }

        return $this->factoryMuffin->instance($name);
    }
752971
public static function factory(array &$data = null, $model = null, $primary = null, $dataLinked = true) {
		return new static($data, $model, $primary, $dataLinked);
	}
764497
private function factory($name)
    {
        $factory = FabricateFactory::create(self::getInstance()->registry->find($name));
        $factory->setConfig(self::getInstance()->config);
        return $factory;
    }
122482
public function factory(string $className, callable $factory):void
    {
        $this->config->registerClassFactory($className, $factory);
    }
1218045
public function registerFactory($factory, $class)
    {
        $this[$factory] = $this->factory(function ($app) use ($class) {
            $obj = new $class;
            if ($obj instanceof FactoryInterface) {
                return $obj->create($app);
            } else {
                return $obj;
            }
        });
    }
1334306
protected static function factory($factory)
    {
        if (is_callable($factory)) {
            return $factory();
        }

        $type = gettype($factory);
        if ($type == 'string' && count(EventManager::instance()->listeners($factory)) > 0) {
            return EventManager::instance()->dispatch($factory)->result;
        }

        throw new \InvalidArgumentException('No suitable factory found');
    }
82293
public function add( $key, $value ) {
		$storage         = $this->storage;
		$storage[ $key ] = $value;

		return new static( $this->get_key_type(), $this->get_value_type(), $storage );
	}
822957
protected function createDriver($driver): Contracts\Factory
    {
        if (\is_null($this->setupDriverConfig($driver))) {
            throw new InvalidArgumentException("Driver [$driver] not supported.");
        }

        return new $this->resolver($this->app, $this, $driver);
    }
977460
public function column($key)
    {
        $result = array_column($this->all(), $key);

        if (empty($result)) {
            $this->each(function ($item) use (&$result, $key) {
                array_push($result, $item->{$key});
            });
        }

        return new static($result);
    }
1026959
public static function factory($name)
    {
        $classname = get_called_class();

        if (!isset(self::$instances[$classname])) {
            self::$instances[$classname] = array();
        }

        if ($name instanceof Value) {
            $name = $name->getValue();
        }

        if (!isset(self::$instances[$classname][$name])) {
            $instance = new static($name);
            $name = $instance->getName();

            if (!isset(self::$instances[$classname][$name])) {
                self::$instances[$classname][$name] = $instance;
            }
        }

        return self::$instances[$classname][$name];
    }
87368
public function getFactory(string $key)
    {
        if(!$this->isFactory($key)) {
            throw new OffsetNotFound("Trying to get a factory offset that doesn't exist");
        }

        return $this[self::REFLECTOR_FACTORY][$key];
    }
296047
public function make($key)
    {
        if (isset($this->factories[$key])) {
            return call_user_func_array(
                $this->factories[$key],
                array_merge([$this], $this->parameters)
            );
        }

        if (isset($this->instances[$key])) {
            return $this->instances[$key];
        }

        if (!isset($this->registers[$key])) {
            return $this->resolve($key);
        }

        if (is_callable($this->registers[$key])) {
            return $this->instances[$key] = call_user_func_array(
                $this->registers[$key],
                array_merge([$this], $this->parameters)
            );
        }

        if (!is_object($this->registers[$key])) {
            return $this->instances[$key] = $this->resolve($key);
        }

        if (method_exists($this->registers[$key], '__invoke')) {
            return  $this->instances[$key] = $this->registers[$key]();
        }

        return null;
    }
1219582
function factory($key, $factory)
	{
		if($factory instanceof Factory)
		{
			$this->_registry[$key] = function() use($factory) {
				return $factory->create();
			};
		}
		else if(is_callable($factory))
		{
			$this->_registry[$key] = $factory;
		}
		else
		{
			throw new RegistryException(
				"Parameter must be a Factory or Closure");
		}

		return $this;
	}