public static function isProgramInstalled($program)
{
// programs with an invalid name do not exist
if (false !== strpbrk($program, self::FORBIDDEN_CHARS)) {
return false;
}
$isExecutable = self::isExecutableName($program);
$paths = explode(self::PATH_SEPARATOR, getenv('PATH'));
array_unshift($paths, getcwd());
$exts = self::getInstance()->getExecuteableExtesions();
foreach ($paths as $path) {
if (!is_dir($path)) {
continue;
}
$file = $path . '/' . $program;
if ($isExecutable && is_readable($file)) {
return true;
}
foreach ($exts as $ext => $index) {
$fileEx = $file . $ext;
if (is_readable($fileEx)) {
return true;
}
}
}
return false;
}