Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
57.14% |
4 / 7 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| OperatingSystem | |
57.14% |
4 / 7 |
|
0.00% |
0 / 1 |
6.97 | |
0.00% |
0 / 1 |
| __construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| getSystem | |
57.14% |
4 / 7 |
|
0.00% |
0 / 1 |
5.26 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package phpOMS\System |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace phpOMS\System; |
| 16 | |
| 17 | /** |
| 18 | * Operating system class. |
| 19 | * |
| 20 | * @package phpOMS\System |
| 21 | * @license OMS License 2.0 |
| 22 | * @link https://jingga.app |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | final class OperatingSystem |
| 26 | { |
| 27 | /** |
| 28 | * Constructor. |
| 29 | * |
| 30 | * @since 1.0.0 |
| 31 | * @codeCoverageIgnore |
| 32 | */ |
| 33 | private function __construct() |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get OS. |
| 39 | * |
| 40 | * @return int |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | */ |
| 44 | public static function getSystem() : int |
| 45 | { |
| 46 | if (\stristr(\PHP_OS, 'DAR') !== false) { |
| 47 | return SystemType::OSX; |
| 48 | } elseif (\stristr(\PHP_OS, 'WIN') !== false) { |
| 49 | return SystemType::WIN; |
| 50 | } elseif (\stristr(\PHP_OS, 'LINUX') !== false) { |
| 51 | return SystemType::LINUX; |
| 52 | } |
| 53 | |
| 54 | return SystemType::UNKNOWN; |
| 55 | } |
| 56 | } |