/**
* Returns a reference to the global CliApplication object, only creating it if it doesn't already exist.
*
* This method must be invoked as: $cli = CliApplication::getInstance();
*
* @param string $name The name (optional) of the Application Cli class to instantiate.
*
* @return CliApplication
*
* @since 1.7.0
* @deprecated 5.0 Load the app through the container
* @throws \RuntimeException
*/
public static function getInstance($name = null)
{
// Only create the object if it doesn't exist.
if (empty(static::$instance)) {
if (!class_exists($name)) {
throw new \RuntimeException(sprintf('Unable to load application: %s', $name), 500);
}
static::$instance = new $name();
}
return static::$instance;
}