Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2400'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Sep 21, 2012
2 parents 3c492ce + 6079de9 commit 06689fb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ abstract class Console
*/
protected static $instance;

/**
* Allow overriding whether or not we're in a console env. If set, and
* boolean, returns that value from isConsole().
* @var bool
*/
protected static $isConsole;

/**
* Create and return Adapter\AdapterInterface instance.
*
Expand Down Expand Up @@ -125,13 +132,29 @@ public static function isAnsicon()
/**
* Check if running in a console environment (CLI)
*
* By default, returns value of PHP_SAPI global constant. If $isConsole is
* set, and a boolean value, that value will be returned.
*
* @return bool
*/
public static function isConsole()
{
if (null !== static::$isConsole && is_bool(static::$isConsole)) {
return static::$isConsole;
}
return PHP_SAPI == 'cli';
}

/**
* Override the "is console environment" flag
*
* @param null|bool $flag
*/
public static function overrideIsConsole($flag)
{
static::$isConsole = $flag;
}

/**
* Try to detect best matching adapter
* @return string|null
Expand Down

0 comments on commit 06689fb

Please sign in to comment.