Total Complexity | 6 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
17 | class System |
||
18 | { |
||
19 | /** |
||
20 | * OS object representation matching current OS |
||
21 | * |
||
22 | * @var OsInterface |
||
23 | */ |
||
24 | protected $os; |
||
25 | |||
26 | /** |
||
27 | * Constructor |
||
28 | * |
||
29 | * @param array $customs Array of custom OS class names can be added here |
||
30 | */ |
||
31 | public function __construct(array $customs = []) |
||
32 | { |
||
33 | $defaults = [ |
||
34 | Linux::class, |
||
35 | Mac::class, |
||
36 | ]; |
||
37 | |||
38 | $this->registerOs(array_merge($customs, $defaults)); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Register array of OS class and pick the one in use |
||
43 | * |
||
44 | * @param array $classNames |
||
45 | */ |
||
46 | public function registerOs(array $classNames) |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Returns currently used OS object |
||
66 | * |
||
67 | * @return OsInterface |
||
68 | */ |
||
69 | public function getOs() |
||
72 | } |
||
73 | } |
||
74 |