AppserverIo\Appserver\Core\Utilities\FileSystem::getOsIdentifier PHP Method

getOsIdentifier() public static method

Will return a three character OS identifier e.g. WIN or LIN
public static getOsIdentifier ( ) : string
return string
    public static function getOsIdentifier()
    {
        return strtoupper(substr(PHP_OS, 0, 3));
    }

Usage Example

 /**
  * Helper method which allows to execute a callable as the super user the server got started by.
  *
  * @param callable $callable  The callable to run
  * @param array    $arguments Arguments to pass to the callable
  *
  * @return mixed The callables result
  */
 public static function sudo(callable $callable, array $arguments = array())
 {
     // don't do anything under Windows
     if (FileSystem::getOsIdentifier() === FileSystem::OS_IDENTIFIER_WIN) {
         return call_user_func_array($callable, $arguments);
     }
     // get the current user user pair (super user and effective user)
     $currentUserId = (int) posix_geteuid();
     $superUserId = (int) posix_getuid();
     // temporarily switch to the super user
     posix_seteuid($superUserId);
     // execute the callable
     $result = call_user_func_array($callable, $arguments);
     // switch back to the effective user
     posix_seteuid($currentUserId);
     return $result;
 }
All Usage Examples Of AppserverIo\Appserver\Core\Utilities\FileSystem::getOsIdentifier