Return a specific instance, or the default instance (is created if necessary)

@param   string  instance name
@return  Asset_Instance
422927
public static function instance($instance = null)
	{
		if ($instance !== null)
		{
			if ( ! array_key_exists($instance, static::$_instances))
			{
				return false;
			}

			return static::$_instances[$instance];
		}

		if (static::$_instance === null)
		{
			static::$_instance = static::forge();
		}

		return static::$_instance;
	}
22119
public static function get($name)
    {
        $class = get_called_class();
    
        if (!isset(self::$instance[$class])) {
            self::$instance[$class] = new static();
        }
        
        return self::$instance[$class]->getExtensions()->get($name);
    }
560037
static public function getInstance($instanceName)
    {
        if (!isset(self::$instanceArray[$instanceName])) {
            self::$instanceArray[$instanceName] = new MDatabaseConnection();
        }
        return self::$instanceArray[$instanceName];
    }
1234506
public function instance($instance = null)
    {
        $instance = $instance ?: self::DEFAULT_INSTANCE;

        $this->instance = sprintf('%s.%s', 'cart', $instance);

        return $this;
    }
1133101
public static function saveInstance($name)
  {
    $adapter = self::getDataAdapter();
    if (!is_null($adapter)) {
      $config = self::getInstance($name);
      $key = self::_instanceKey($name);
      
      $result = $adapter->save($key, $config);
    } else {
      $result = false;
    }
    
    return $result;
  }
1341299
protected static function resolveFacadeInstance($name)
    {
        if (is_object($name)) {
            return $name;
        }
        if (isset(static::$instance[$name])) {
            return static::$instance[$name];
        }

        return static::$instance[$name] = static::$app->get($name);
    }
988174
private function findInstanceByCallbackType($instanceName) {
		// Note: we execute the code in another thread. Always.
		// This prevent crashing the main thread.
		try {
			$fullyQualifiedClassName = MoufReflectionProxy::getReturnTypeFromCode($this->declaredInstances[$instanceName]["code"], $this->getScope() == self::SCOPE_ADMIN);
			unset($this->declaredInstances[$instanceName]["error"]);
			unset($this->declaredInstances[$instanceName]["constructor"]);
			unset($this->declaredInstances[$instanceName]["fieldProperties"]);
			unset($this->declaredInstances[$instanceName]["setterProperties"]);
			unset($this->declaredInstances[$instanceName]["fieldBinds"]);
			unset($this->declaredInstances[$instanceName]["setterBinds"]);
			$this->declaredInstances[$instanceName]["class"] = $fullyQualifiedClassName;
		} catch (\Exception $e) {
			$this->declaredInstances[$instanceName]["error"] = $e->getMessage();
			unset($this->declaredInstances[$instanceName]["class"]);
			$fullyQualifiedClassName = null;
		}
		return $fullyQualifiedClassName;
	}
73043
protected function instance($name)
    {
        $methodName = $this->methodName($name);

        return $this->objectBuild($name, $methodName);
    }
349472
public static function getInstance($name, ...$args)
    {
        if (empty(static::$instances[$name])) {
            static::$instances[$name] = new static(...$args);
        }

        return static::$instances[$name];
    }
670616
public static function getInstance(string $name): Base
    {
        if(!isset(static::$handlers[$name]))
        {
            throw new \RuntimeException(sprintf('GetInstance failed, %s is not found', $name));
        }
        return static::$handlers[$name];
    }
16904
public static function assets($assetName = null)
	{
		//get the server name from global $_SERVER[] array()
		$base  = $_SERVER['SERVER_NAME']; 

		$url = Registry::getUrl();

		//check if there is a uri string
		if ( ! empty($url) ) 
		{
			//prepend installation folder to server name
			$base .= substr($_SERVER['REQUEST_URI'], 0,  strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));

		}
		//there is no query string, 
		else
		{
			//prepend installation folder to server name
			$base .= substr($_SERVER['REQUEST_URI'], 0);

		}


    	//use https if its defined in the $_SERVER global variable
    	$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";

		//compose the url string
		return $protocol . '://' . $base . 'public/' . $assetName;

	}
496678
public function getInstance()
    {
        if ( ! $class = $this->getClassName())
        {
            $this->log->error(sprintf('"%s" will not be applied to asset "%s" due to an invalid filter name.', $this->filter, $this->resource->getRelativePath()));
        }

        if ($this->ignored or is_null($class) or ! $this->processRequirements()) return;

        // If the class returned is already implements Assetic\Filter\FilterInterface then
        // we can set the instance directly and not worry about using reflection.
        if ($class instanceof FilterInterface)
        {
            $instance = $class;
        }
        else
        {
            $reflection = new ReflectionClass($class);

            // If no constructor is available on the filters class then we'll instantiate
            // the filter without passing in any arguments.
            if ( ! $reflection->getConstructor())
            {
                $instance = $reflection->newInstance();
            }
            else
            {
                $instance = $reflection->newInstanceArgs($this->arguments);
            }
        }

        // Spin through each of the before filtering callbacks and fire each one. We'll
        // pass in an instance of the filter to the callback.
        foreach ($this->before as $callback)
        {
            if (is_callable($callback))
            {
                call_user_func($callback, $instance);
            }
        }

        return $instance;
    }
534244
public function instance($name)
    {
        if (empty($this->instances[$name])) {
            if (empty($this->aliases[$name])) {
                $this->aliasDefault($name);
            }
            $this->instances[$name] = new $this->aliases[$name];
        }

        return $this->instances[$name];
    }
1138473
public static function getInstance($name)
  {
    $key = self::_instanceKey($name);
    if (!isset(self::$_instances[$key])) {

      $dataSource = self::getDataAdapter();
      if (is_null($dataSource)) {
        $data = array();
      } else {
        $data = $dataSource->load($key);
      }
      
      $config = new self($data);
      /* @var $config Config */
      $config->_root = $config;
      $config->_key = $key;

      self::$_instances[$key] = $config;
    }
    return self::$_instances[$key];
  }
522692
public function instance($name, array $instance = [])
    {
        return new Instance(
            $this->connection,
            $this->lroConnection,
            $this->lroCallables,
            $this->projectId,
            $name,
            $this->returnInt64AsObject,
            $instance
        );
    }
887994
public function &getAppInstance(string $name)
    {
        if (empty($name)) {
            Throw new FrameworkException('Core::getAppInstance() needs an app name');
        }

        $string = new CamelCase($name);
        $name = $string->camelize();

        // App instances are singletons!
        if (!array_key_exists($name, $this->apps)) {

            // Create class name
            $class = '\Apps\\' . $name . '\\' . $name;

            //
            $filename = $this->basedir . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';

            if (!file_exists($filename)) {
                Throw new FrameworkException(sprintf('Apps could not find an app classfile "%s" for app "%s"', $name, $filename));
            }

            // Default arguments for each app instance
            $args = [
                $name,
                $this->config->createStorage($name),
                $this
            ];

            $instance = $this->di->instance($class, $args);

            if (!$instance instanceof AbstractApp) {
                Throw new FrameworkException('Apps must be an instance of AbstractApp class!');
            }

            $instance->setName($name);
            $instance->language->setCode($this->config->get('Core', 'site.language.default'));

            $this->apps[$name] = $instance;
        }

        return $this->apps[$name];
    }
457453
public static function instance($name = 'default')
	{
		if (\array_key_exists($name, static::$instances))
		{
			return static::$instances[$name];
		}

		if (empty(static::$instances))
		{
			\Config::load('db', true);
		}

		if ( ! ($config = \Config::get('db.mongo.'.$name)))
		{
			throw new \Mongo_DbException('Invalid instance name given.');
		}

		static::$instances[$name] = new static($config);

		return static::$instances[$name];
	}