| Total Complexity | 20 |
| Total Lines | 95 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class Plateform |
||
| 14 | { |
||
| 15 | const OS_UNKNOWN = 1; |
||
| 16 | const OS_WIN = 2; |
||
| 17 | const OS_LINUX = 3; |
||
| 18 | const OS_OSX = 4; |
||
| 19 | |||
| 20 | protected static $pharPath; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Running from Phar or not? |
||
| 24 | * |
||
| 25 | * @return bool |
||
| 26 | */ |
||
| 27 | public static function isPhar(): bool |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Returns the full path on disk to the currently executing Phar archive. |
||
| 40 | * |
||
| 41 | * @return string |
||
| 42 | */ |
||
| 43 | public static function getPharPath(): string |
||
| 44 | { |
||
| 45 | if (!isset(self::$pharPath)) { |
||
| 46 | self::isPhar(); |
||
| 47 | } |
||
| 48 | |||
| 49 | return self::$pharPath; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Whether the host machine is running a Windows OS. |
||
| 54 | * |
||
| 55 | * @return bool |
||
| 56 | */ |
||
| 57 | public static function isWindows(): bool |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Opens a URL in the system default browser. |
||
| 64 | * |
||
| 65 | * @param string $url |
||
| 66 | * |
||
| 67 | * @return void |
||
| 68 | */ |
||
| 69 | public static function openBrowser($url): void |
||
| 70 | { |
||
| 71 | if (self::isWindows()) { |
||
| 72 | passthru('start "web" explorer "'.$url.'"'); |
||
| 73 | |||
| 74 | return; |
||
| 75 | } |
||
| 76 | passthru('which xdg-open', $linux); |
||
| 77 | passthru('which open', $osx); |
||
| 78 | if (0 === $linux) { |
||
| 79 | passthru('xdg-open '.$url); |
||
| 80 | } elseif (0 === $osx) { |
||
| 81 | passthru('open '.$url); |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Search for system OS in PHP_OS constant. |
||
| 87 | * |
||
| 88 | * @return int |
||
| 89 | */ |
||
| 90 | public static function getOS(): int |
||
| 108 | } |
||
| 109 | } |
||
| 111 |