File tree Expand file tree Collapse file tree 4 files changed +15
-1
lines changed Expand file tree Collapse file tree 4 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 33## Not released yet  
44
55*  Remove mb_string extension requirement
6+ *  Add Docker support
67
78## 0.1.0 (2023-12-03)  
89
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ OsHelper::isWindowsSeven(); // true or false
2121OsHelper::isWindowsEightOrHigher(); // true or false
2222OsHelper::isWindowsSubsystemForLinux(); // true or false
2323OsHelper::isMacOs(); // true or false
24+ OsHelper::isDocker(); // true or false
2425OsHelper::getMacOSVersion(); // 10.15.7
2526``` 
2627
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ public static function isUnix(): bool
1515
1616    public  static  function  isWindowsSubsystemForLinux (): bool 
1717    {
18-         return  self ::isUnix () && str_contains (strtolower (php_uname ()), 'microsoft ' );
18+         return  ! self :: isDocker () &&  self ::isUnix () && str_contains (strtolower (php_uname ()), 'microsoft ' );
1919    }
2020
2121    public  static  function  isWindows (): bool 
@@ -50,6 +50,11 @@ public static function isMacOS(): bool
5050        return  str_contains (self ::$ kernelName'Darwin ' );
5151    }
5252
53+     public  static  function  isDocker (): bool 
54+     {
55+         return  file_exists ('/.dockerenv ' ) || (file_exists ('/proc/self/cgroup ' ) && false  !== mb_strpos (file_get_contents ('/proc/self/cgroup ' ) ?: '' , 'docker ' ));
56+     }
57+ 
5358    public  static  function  getMacOSVersion (): string 
5459    {
5560        if  (!isset (self ::$ macOSVersion
Original file line number Diff line number Diff line change @@ -65,6 +65,13 @@ public function testIsMacOS()
6565        $ this assertSame ($ isDarwinisMacOS ());
6666    }
6767
68+     public  function  testIsDocker ()
69+     {
70+         $ isDockerfile_exists ('/.dockerenv ' ) || (file_exists ('/proc/self/cgroup ' ) && false  !== mb_strpos (file_get_contents ('/proc/self/cgroup ' ) ?: '' , 'docker ' ));
71+ 
72+         $ this assertSame ($ isDockerisDocker ());
73+     }
74+ 
6875    public  function  testGetMacOSVersion ()
6976    {
7077        if  (!OsHelper::isMacOS ()) {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments