OS

@param string
776865
public static function os() : String
    {
        if( stristr(PHP_OS, 'WIN') )
        {
            return 'WIN';
        }
        elseif( stristr(PHP_OS, 'MAC') )
        {
            return 'MAC';
        }
        elseif( stristr(PHP_OS, 'LINUX') )
        {
            return 'LINUX';
        }
        elseif( stristr(PHP_OS, 'UNIX') )
        {
            return 'UNIX';
        }
        else
        {
            return 'UNKNOWN';
        }
    }
656876
@SuppressWarnings("index") // dependent: os[1] is legal when optionLength(os[0])==2
  public void setOptions(String[] @MinLen(1) [] options) {
    String outFilename = null;
    File destDir = null;
    for (int oi = 0; oi < options.length; oi++) {
      String[] os = options[oi];
      String opt = os[0].toLowerCase();
      if (opt.equals("-docfile")) {
        this.docFile = new File(os[1]);
      } else if (opt.equals("-d")) {
        destDir = new File(os[1]);
      } else if (opt.equals("-outfile")) {
        outFilename = os[1];
      } else if (opt.equals("-i")) {
        this.inPlace = true;
      } else if (opt.equals("-format")) {
        if (os[1].equals("javadoc")) {
          setFormatJavadoc(true);
        }
      } else if (opt.equals("-classdoc")) {
        this.includeClassDoc = true;
      } else if (opt.equals("-singledash")) {
        setUseSingleDash(true);
      }
    }
    if (outFilename != null) {
      if (destDir != null) {
        this.outFile = new File(destDir, outFilename);
      } else {
        this.outFile = new File(outFilename);
      }
    }
  }
606172
public function eat($string)
    {
        $state = $this->captureState();
        if ($string === $this->read(strlen($string), true)) {
            return true;
        } else {
            $state->restore();

            return false;
        }
    }
311603
public function operatingSystem()
    {
        $UserAgent = self::agent();
        if (preg_match_all('/windows/i', $UserAgent)) {
            $PlatForm = 'Windows';
        } elseif (preg_match_all('/linux/i', $UserAgent)) {
            $PlatForm = 'Linux';
        } elseif (preg_match('/macintosh|mac os x/i', $UserAgent)) {
            $PlatForm = 'Macintosh';
        } elseif (preg_match_all('/Android/i', $UserAgent)) {
            $PlatForm = 'Android';
        } elseif (preg_match_all('/iPhone/i', $UserAgent)) {
            $PlatForm = 'IOS';
        } elseif (preg_match_all('/ubuntu/i', $UserAgent)) {
            $PlatForm = 'Ubuntu';
        } else {
            $PlatForm = 'unknown';
        }

        return $PlatForm;
    }
826564
static function PathExecutable($in_path)
    {
        $perms = fileperms($in_path);

        if (!is_dir($in_path)) {
            return false;
        }

        if (!strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && is_executable($in_path)) {
            return false;
        }

        if (!is_writeable($in_path)) {
            return false;
        }

        return true;
    }
1080992
public function loadString($string)
    {
        $this->sourceString = $string;

        if ($this->config->allowPhpScripts === false) {
            $this->sourceString = preg_replace(
                '/<\\?.*(\\?>|$)/Us',
                '',
                str_replace('<?=', '<?php echo ', $this->sourceString)
            );
        }

        $this->sourceString = str_replace(
            [
                '__DIR__',
                '__FILE__',
            ],
            [
                "'" . $this->getSourceFileDirectory() . "'",
                "'" . $this->getSourceFilePath() . "'",
            ],
            $this->sourceString
        );

        return empty($this->sourceString);
    }
1254287
public static boolean isLinux(String os) {
        if (os == null) {
            return false;
        }
        String operating = os.toLowerCase();
        return operating.contains("nix") || operating.contains("nux") || operating.contains("aix");
    }
669359
public static function initializeByString($string) {
        $Object = json_decode($string);
        $result = self::checkStatus($Object->status);
        if ($result === true) {
            $Status = new self();
            $Status->setStatus($Object->status)
                ->setReceipt(Receipt::initializeByObject($Object->receipt));
            return $Status;
        } else {
            $Exception = new $result($string, $Object->status);
            throw $Exception;
        }
    }
1062149
public function restart()
    {

        // load the OS signature
        $os = php_uname('s');

        // log the found OS
        $this->getSystemLogger()->debug(
            "Found operating system: $os"
        );

        // check what OS we are running on
        switch ($os) {

            // If we got a Linux distribution we have to check which one
            case DeploymentScanner::LINUX:

                // Get the distribution
                $distribution = $this->getLinuxDistribution();
                // If we did not get anything
                if (!$distribution) {
                    // Log the error
                    $this->getSystemLogger()->error(
                        "The used Linux distribution could not be determined, it might not be supported."
                    );

                    // End here
                    return;
                }

                // determine the version of the found distribution
                $distVersion = $this->getDistributionVersion($distribution);

                // log the found distribution
                $this->getSystemLogger()->debug(
                    "Found Linux distribution: $distribution"
                );

                // Execute the restart command for the distribution
                exec($this->getRestartCommand($distribution . $os, $distVersion));
                break;

            // Restart with the Mac or Windows command
            case DeploymentScanner::DARWIN:
            case DeploymentScanner::WINDOWS_NT:
                exec($this->getRestartCommand($os));
                break;

            // all other OS are NOT supported actually
            default:
                $this->getSystemLogger()->error(
                    "OS $os does not support auto restart"
                );
                break;
        }
    }
1097774
function set(os) {
    if (!(os instanceof OperatingSystem)) return false;

    return Object.defineProperty(this, 'os', {
      value: os
    }).os;
  }
653858
public function parse($string)
    {
        // Reset values
        $this->isBrowser = false;
        $this->isRobot = false;
        $this->isMobile = false;
        $this->browser = '';
        $this->browserVersion = '';
        $this->mobile = '';
        $this->robot = '';

        // Set the new user-agent string and parse it, unless empty
        $this->string = $string;

        if ( ! empty($string)) {
            $this->compileData();
        }
    }
676264
public static function getOS()
    {
        if (self::$nb_os === null) {
            self::$nb_os = new CNabuOS();
            self::$nb_os->init();
        }

        return self::$nb_os;
    }
461225
public function fromString($string)
    {
        $fs = new Filesystem();
        $dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.'gush';

        if (!file_exists($dir)) {
            $fs->mkdir($dir);
        }

        $tmpName = tempnam($dir, '');
        file_put_contents($tmpName, $string);
        $editor = getenv('EDITOR');

        if (!$editor) {
            throw new \RuntimeException('No EDITOR environment variable set.');
        }

        if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
            $processHelper = $this->getHelperSet()->get('process');
            /** @var ProcessHelper $processHelper */
            $process = $processHelper->getProcessBuilder($editor.' '.escapeshellarg($tmpName))->getProcess();
            $process->setTimeout(null);
            $process->start();

            // Wait till editor closes
            $process->wait();
        } else {
            system($editor.' '.$tmpName.' > `tty`');
        }

        $contents = file_get_contents($tmpName);
        $fs->remove($tmpName);

        return $contents;
    }
324527
public function unserialize($string)
    {
        $this->objectId = null;
        $this->setData([]);

        if ($string == '') {
            return;
        }

        $data = unserialize($string);
        if (is_array($data)) {
            $data = array_merge(['id' => null, 'data' => []], $data);
            $this->objectId = $data['id'];
            $this->objectData = $data['data'];
            unset($this->objectData['id']);
        }
    }
828334
public function getOs($attr = '')
    {
        if ($attr == '') {
            return $this->os;
        }

        if (!isset($this->os[$attr])) {
            return self::UNKNOWN;
        }

        return $this->os[$attr];
    }
1305867
public function parse( $string )
	{
		if( !is_string( $string ) )														//  no String given
			throw new InvalidArgumentException( 'Given argument is not a string' );		//  throw Exception

		$this->extendPossibleOptionsWithShortcuts();									//  realize Shortcuts

		$position	= 0;																//  initiate Sign Pointer
		$status		= self::STATUS_START;												//  initiate Status
		$buffer		= "";																//  initiate Argument Buffer
		$option		= "";																//  initiate Option Buffer

		while( isset( $string[$position] ) )											//  loop until End of String
		{
			$sign	= $string[$position];												//  get current Sign
			$position ++;																//  increase Sign Pointer

			switch( $status )															//  handle Sign depending on Status
			{
				case self::STATUS_START:												//  open for all Signs
					$this->onReady( $sign, $status, $buffer, $option );					//  handle Sign
					break;
				case self::STATUS_READ_OPTION_KEY:										//  open for Option Key Signs
					$this->onReadOptionKey( $sign, $status, $buffer, $option );			//  handle Sign
					break;
				case self::STATUS_READ_OPTION_VALUE:									//  open for Option Value Signs
					$this->onReadOptionValue( $sign, $status, $buffer, $option );		//  handle Sign
					break;
				case self::STATUS_READ_ARGUMENT:										//  open for Argument Signs
					$this->onReadArgument( $sign, $status, $buffer );					//  handle Sign
					break;
			}
		}
		$this->onEndOfLine( $status, $buffer, $option );								//  close open States
	}
614550
public function mapPlatformKey(?string $osVersion, ?string $platform = null): ?string
    {
        if (null === $osVersion) {
            return 'unknown';
        }

        switch (mb_strtolower($osVersion)) {
            case '':
            case 'unknown':
            case 'other':
                return 'unknown';
                break;
            case 'server 2003':
                return 'windows 2003';
                break;
            case 'nt 5.1':
                return 'windows nt 5.1';
                break;
            case 'nt 5.2':
                return 'windows nt 5.2';
                break;
            case 'nt 5.3':
                return 'windows nt 5.3';
                break;
            case 'nt 6.0':
                return 'windows nt 6.0';
                break;
            case 'nt 6.1':
                return 'windows nt 6.1';
                break;
            case 'nt 6.2':
                return 'windows nt 6.2';
                break;
            case 'nt 6.3':
                return 'windows nt 6.3';
                break;
            default:
                // nothing to do here
                break;
        }

        if (null === $platform) {
            return 'unknown';
        }

        switch (mb_strtolower($platform)) {
            case '':
            case 'unknown':
            case 'other':
                return 'unknown';
                break;
            case 'winxp':
            case 'windows xp':
                switch (mb_strtolower($osVersion)) {
                    case '5.1':
                        return 'windows nt 5.1';
                        break;
                    case '5.2':
                        return 'windows nt 5.2';
                        break;
                    default:
                        // do nothing
                }

                return 'windows nt 5.1';
                break;
            case 'win7':
            case 'windows 7':
                return 'windows nt 6.1';
                break;
            case 'win8':
            case 'windows 8':
                return 'windows nt 6.2';
                break;
            case 'win8.1':
            case 'windows 8.1':
                return 'windows nt 6.3';
                break;
            case 'winvista':
            case 'windows vista':
                return 'windows nt 6.0';
                break;
            case 'win2003':
                return 'windows 2003';
                break;
            case 'win98':
            case 'windows 98':
                return 'windows 98';
                break;
            case 'win95':
                return 'windows 95';
                break;
            case 'win2000':
            case 'windows 2000':
                switch (mb_strtolower($osVersion)) {
                    case '5.01':
                        return 'windows nt 5.01';
                        break;
                    case '5.0':
                        return 'windows nt 5.0';
                        break;
                    default:
                        // do nothing
                }

                return 'windows nt 5.0';
                break;
            case 'winme':
                return 'windows me';
                break;
            case 'win9':
            case 'win10':
            case 'windows 10':
                switch (mb_strtolower($osVersion)) {
                    case '6.4':
                        return 'windows nt 6.4';
                        break;
                    case '10.0':
                        return 'windows nt 10.0';
                        break;
                    default:
                        // do nothing
                }

                return 'windows nt 10.0';
                break;
            case 'win31':
                if ('3.11' === mb_strtolower($osVersion)) {
                    return 'windows 3.11';
                }

                return 'windows 3.1';
                break;
            case 'wince':
                return 'windows ce';
                break;
            case 'winnt':
                switch (mb_strtolower($osVersion)) {
                    case '3.1':
                        return 'windows nt 3.1';
                        break;
                    case '3.5':
                        return 'windows nt 3.5';
                        break;
                    case '4.0':
                        return 'windows nt 4.0';
                        break;
                    case '4.1':
                        return 'windows nt 4.1';
                        break;
                    default:
                        // do nothing
                }

                return 'windows nt';
                break;
            case 'winrt8':
                return 'windows nt 6.2; arm';
                break;
            case 'winrt8.1':
                return 'windows nt 6.3; arm';
                break;
            case 'winphone':
            case 'winphone6':
            case 'winphone7':
            case 'winphone7.5':
            case 'winphone7.10':
            case 'winphone8':
            case 'winphone8.1':
            case 'winphone10':
            case 'windows phone':
            case 'windows phone 7':
                return 'windows phone';
                break;
            case 'winmobile':
                return 'windows mobile os';
                break;
            case 'win32':
            case 'win16':
            case 'windows server':
                return 'windows';
                break;
            case 'rim os':
            case 'blackberry os':
                return 'rim os';
                break;
            case 'rim tablet os':
                return 'rim tablet os';
                break;
            case 'mac':
            case 'macosx':
            case 'os x':
            case 'mac osx':
                return 'mac os x';
                break;
            case 'macppc':
            case 'mac68k':
                return 'macintosh';
                break;
            case 'ios':
                return 'ios';
                break;
            case 'centos':
                return 'cent os linux';
                break;
            case 'jvm':
            case 'java':
                return 'java';
                break;
            case 'bada':
            case 'bada os':
                return 'bada';
                break;
            case 'brew':
                return 'brew';
                break;
            case 'webos':
                return 'webos';
                break;
            case 'symbianos':
                return 'symbian';
                break;
            case 'darwin':
                return 'darwin';
                break;
            case 'aix':
                return 'aix';
                break;
            case 'beos':
                return 'beos';
                break;
            case 'cygwin':
                return 'cygwin';
                break;
            case 'risc os':
                return 'risc os';
                break;
            case 'tru64 unix':
                return 'tru64 unix';
                break;
            case 'nokia series 40':
            case 'symbian os series 40':
                return 'nokia os';
                break;
            case 'gnu/linux':
            case 'linux':
                return 'linux';
                break;
            case 'unix':
                return 'unix';
                break;
            case 'debian':
                return 'debian';
                break;
            case 'ubuntu':
                return 'ubuntu';
                break;
            case 'chrome os':
            case 'chromeos':
                return 'chromeos';
                break;
            case 'mint':
                return 'linux mint';
                break;
            case 'android':
                return 'android';
                break;
            case 'hp-ux':
                return 'hp-ux';
                break;
            case 'bsd':
                return 'bsd';
                break;
            case 'freebsd':
                return 'freebsd';
                break;
            case 'openbsd':
                return 'openbsd';
                break;
            case 'netbsd':
                return 'netbsd';
                break;
            case 'dragonfly bsd':
                return 'dragonfly bsd';
                break;
            case 'sunos':
                return 'sunos';
                break;
            case 'solaris':
                return 'solaris';
                break;
            case 'irix64':
                return 'irix';
                break;
            case 'os/2':
                return 'os/2';
                break;
            case 'meego':
                return 'meego';
                break;
            case 'maemo':
                return 'linux smartphone os (maemo)';
                break;
            case 'tizen':
                return 'tizen';
                break;
            case 'openvms':
                return 'openvms';
                break;
            case 'firefoxos':
            case 'firefox os':
                return 'firefoxos';
                break;
            case 'palmos':
                return 'palmos';
                break;
            case 'amiga os':
                return 'amiga os';
                break;
            case 'cellos':
                return 'cellos';
                break;
            case 'wyderos':
                return 'wyderos';
                break;
            case 'liberate':
                return 'liberate';
                break;
            case 'sailfishos':
                return 'sailfishos';
                break;
            case 'syllable':
                return 'syllable';
                break;
            case 'inferno os':
                return 'inferno os';
                break;
            case 'miui os':
                return 'miui os';
                break;
            default:
                // nothing to do here
                break;
        }

        return 'unknown';
    }