File tree Expand file tree Collapse file tree
libraries/classes/Server/SysInfo
test/classes/Server/SysInfo Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function memory()
4141 /**
4242 * Checks whether class is supported in this environment
4343 */
44- public function supported (): bool
44+ public static function isSupported (): bool
4545 {
4646 return true ;
4747 }
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ public function loadavg()
6666 /**
6767 * Checks whether class is supported in this environment
6868 */
69- public function supported (): bool
69+ public static function isSupported (): bool
7070 {
7171 return @is_readable ('/proc/meminfo ' ) && @is_readable ('/proc/stat ' );
7272 }
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function loadavg()
5757 /**
5858 * Checks whether class is supported in this environment
5959 */
60- public function supported (): bool
60+ public static function isSupported (): bool
6161 {
6262 return @is_readable ('/proc/meminfo ' );
6363 }
Original file line number Diff line number Diff line change @@ -52,23 +52,20 @@ public static function get()
5252
5353 switch ($ php_os ) {
5454 case 'Linux ' :
55- $ sysInfo = new Linux ();
56- if ($ sysInfo ->supported ()) {
57- return $ sysInfo ;
55+ if (Linux::isSupported ()) {
56+ return new Linux ();
5857 }
5958
6059 break ;
6160 case 'WINNT ' :
62- $ sysInfo = new WindowsNt ();
63- if ($ sysInfo ->supported ()) {
64- return $ sysInfo ;
61+ if (WindowsNt::isSupported ()) {
62+ return new WindowsNt ();
6563 }
6664
6765 break ;
6866 case 'SunOS ' :
69- $ sysInfo = new SunOs ();
70- if ($ sysInfo ->supported ()) {
71- return $ sysInfo ;
67+ if (SunOs::isSupported ()) {
68+ return new SunOs ();
7269 }
7370
7471 break ;
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ public function __construct()
4141 * @see https://docs.microsoft.com/en-us/windows/win32/wmisdk/swbemlocator
4242 * @see https://docs.microsoft.com/en-us/windows/win32/wmisdk/swbemservices
4343 *
44- * @psalm-suppress MixedAssignment, UndefinedMagicMethod
44+ * @psalm-suppress MixedAssignment, UndefinedMagicMethod, MixedMethodCall
4545 */
4646 $ this ->wmiService = (new com ('WbemScripting.SWbemLocator ' ))->ConnectServer ();
4747 }
@@ -59,9 +59,9 @@ public function loadavg()
5959 /**
6060 * Checks whether class is supported in this environment
6161 */
62- public function supported (): bool
62+ public static function isSupported (): bool
6363 {
64- return $ this -> wmiService !== null ;
64+ return class_exists ( ' com ' ) ;
6565 }
6666
6767 /**
Original file line number Diff line number Diff line change @@ -67,6 +67,6 @@ public function testGetSysInfo(): void
6767 */
6868 public function testGetSysInfoSupported (): void
6969 {
70- $ this ->assertTrue (SysInfo::get ()-> supported ());
70+ $ this ->assertTrue (SysInfo::get ():: isSupported ());
7171 }
7272}
You can’t perform that action at this time.
0 commit comments