N98\Util\WindowsSystem::isProgramInstalled PHP Method

isProgramInstalled() public static method

a program (by it's basename) is available on system for execution
public static isProgramInstalled ( string $program ) : boolean
$program string
return boolean
    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;
    }