Add some more platform related calls

refs #7163
This commit is contained in:
Johannes Meyer 2014-09-29 11:21:56 +02:00
parent 8fcf21a6b8
commit 5b3d549e5c
1 changed files with 50 additions and 2 deletions

View File

@ -30,6 +30,16 @@ class Platform
*/
protected static $fqdn;
/**
* Return the operating system's name
*
* @return string
*/
public static function getOperatingSystemName()
{
return php_uname('s');
}
/**
* Test of windows
*
@ -37,7 +47,7 @@ class Platform
*/
public static function isWindows()
{
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
return strtoupper(substr(self::getOperatingSystemName(), 0, 3)) === 'WIN';
}
/**
@ -47,7 +57,7 @@ class Platform
*/
public static function isLinux()
{
return strtoupper(substr(PHP_OS, 0, 5)) === 'LINUX';
return strtoupper(substr(self::getOperatingSystemName(), 0, 5)) === 'LINUX';
}
/**
@ -120,6 +130,16 @@ class Platform
}
}
/**
* Return the version of PHP
*
* @return string
*/
public static function getPhpVersion()
{
return phpversion();
}
/**
* Test for php extension
*
@ -131,4 +151,32 @@ class Platform
{
return extension_loaded($extensionName);
}
/**
* Return the value for the given PHP configuration option
*
* @param string $option The option name for which to return the value
*
* @return string|false
*/
public static function getPhpConfig($option)
{
return ini_get($option);
}
/**
* Return whether the given Zend framework class exists
*
* @param string $name The name of the class to check
*
* @return bool
*/
public static function zendClassExists($name)
{
if (class_exists($name)) {
return true;
}
return (@include str_replace('_', '/', $name) . '.php') !== false;
}
}