Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor runningOn()
  • Loading branch information
phil-davis committed Aug 24, 2017
commit b2a7fa3bb73397aa375e489829e2e3003bffa2c9
23 changes: 6 additions & 17 deletions lib/private/legacy/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1252,27 +1252,16 @@ public static function obEnd() {
/**
* Checks whether the server is running on the given OS type
*
* @param string $osType linux|mac|bsd
* @param string $osType linux|mac|bsd etc
* @return bool true if running on that OS type, false otherwise
*/
public static function runningOn($osType) {
$osType = strtolower($osType);
$osType = strtolower($osType) === 'mac' ? 'darwin' : strtolower($osType);

switch($osType) {
case 'linux':
return (strtolower(substr(PHP_OS, 0, 5)) === 'linux');
break;

case 'mac':
return (strtolower(substr(PHP_OS, 0, 6)) === 'darwin');
break;

case 'bsd':
return (strpos(strtolower(PHP_OS), 'bsd') !== false);
break;

default;
return false;
if ($osType === 'bsd') {
return (strpos(strtolower(PHP_OS), $osType) !== false);
} else {
return (strtolower(substr(PHP_OS, 0, strlen($osType))) === $osType);
}
}

Expand Down