3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Server\SysInfo
;
13 * Library for extracting information about system memory and cpu.
14 * Currently supports all Windows and Linux platforms
16 * This code is based on the OS Classes from the phpsysinfo project
17 * (https://phpsysinfo.github.io/phpsysinfo/)
21 public const MEMORY_REGEXP
= '/^(MemTotal|MemFree|Cached|Buffers|SwapCached|SwapTotal|SwapFree):\s+(.*)\s*kB/im';
24 * Returns OS type used for sysinfo class
26 * @param string $phpOs PHP_OS constant
28 public static function getOs(string $phpOs = PHP_OS
): string
30 // look for common UNIX-like systems
31 if (in_array($phpOs, ['FreeBSD', 'DragonFly'], true)) {
35 return ucfirst($phpOs);
39 * Gets SysInfo class matching current OS
41 * @return Base sysinfo class
43 public static function get(): Base
45 $phpOs = self
::getOs();
49 if (Linux
::isSupported()) {
55 if (WindowsNt
::isSupported()) {
56 return new WindowsNt();
61 if (SunOs
::isSupported()) {