resolver = $resolver; $this->class = $class; $this->params = $params; $this->setters = $setters; } /** * * Invoke the Factory object as a function to use the Factory to create * a new instance of the specified class; pass sequential parameters as * as yet another set of constructor parameter overrides. * * Why the overrides for the overrides? So that any package that needs a * factory can make its own, using sequential params in a function; then * the factory call can be replaced by a call to this Factory. * * @return object * */ public function __invoke() { $params = array_merge($this->params, func_get_args()); $resolve = $this->resolver->resolve( $this->class, $params, $this->setters ); $object = $resolve->reflection->newInstanceArgs($resolve->params); foreach ($resolve->setters as $method => $value) { $object->$method($value); } return $object; } }