for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace AlecRabbit\Cli\Tools;
use const AlecRabbit\ENV_COLORTERM;
use const AlecRabbit\ENV_DOCKER_TERM;
use const AlecRabbit\ENV_TERM;
use const AlecRabbit\NEEDLE_256_COLOR;
use const AlecRabbit\NEEDLE_TRUECOLOR;
use const AlecRabbit\XTERM;
class EnvCheck
{
/**
* @return bool
*/
public static function isXterm(): bool
return
static::checkEnvVariable(ENV_TERM, XTERM) ||
static::checkEnvVariable(ENV_DOCKER_TERM, XTERM);
}
* @param string $varName
* @param string $checkFor
protected static function checkEnvVariable(string $varName, string $checkFor): bool
if ($t = getenv($varName)) {
false !== strpos($t, $checkFor);
return false;
public static function has256ColorSupport(): bool
static::checkEnvVariable(ENV_TERM, NEEDLE_256_COLOR) ||
static::checkEnvVariable(ENV_DOCKER_TERM, NEEDLE_256_COLOR);
public static function hasTrueColorSupport(): bool
static::checkEnvVariable(ENV_COLORTERM, NEEDLE_TRUECOLOR);