objects = $objects; } /** * Creates and returns an instance of the given object. * * @param $object * * @return object */ public function getObject($object) { if (!isset($this->instances[$object])) { $definition = $this->objects[$object]; $this->instances[$object] = ($definition instanceof Closure) ? $definition() : new $definition(); } return $this->instances[$object]; } /** * Returns true if the given object is defined in the factory. * * @param string $object * * @return bool */ public function hasObject($object) { return isset($this->objects[$object]); } }