1 | <?php |
||
13 | class Detector |
||
14 | { |
||
15 | /** |
||
16 | * @return string Path to directory with xml data files |
||
17 | */ |
||
18 | public function getPathToData() |
||
22 | |||
23 | /** |
||
24 | * @return array Xml data object |
||
25 | */ |
||
26 | public function getXmlData() |
||
30 | |||
31 | /** |
||
32 | * @param string $PathToData |
||
33 | */ |
||
34 | public function setPathToData($PathToData) |
||
38 | |||
39 | /** |
||
40 | * @param array $xmlData Xml data object |
||
41 | */ |
||
42 | public function setXmlData($xmlData) |
||
46 | /** @var string Path to directory with xml data */ |
||
47 | private $PathToData; |
||
48 | |||
49 | /** @var array Xml Data */ |
||
50 | private $xmlData; |
||
51 | |||
52 | /** |
||
53 | * Detector constructor. |
||
54 | * @param string $pathToData Path to directory with xml data files |
||
55 | */ |
||
56 | private function __construct($pathToData='auto') |
||
71 | |||
72 | public static function Analyse($uaString='UA',$pathToData='auto') |
||
115 | |||
116 | /** |
||
117 | * @param array $xmlData Xml data array |
||
118 | * @param string $key Key in data array |
||
119 | * @param string $uaString User agent |
||
120 | * @return \SimpleXMLElement xml element |
||
121 | */ |
||
122 | private static function analysePart($xmlData,$key,$uaString) |
||
135 | |||
136 | /** |
||
137 | * @param \SimpleXMLElement $xmlItem xmlItem |
||
138 | * @param string $uaString User agent |
||
139 | * @return string Version |
||
140 | */ |
||
141 | private static function getVersion($xmlItem,$uaString) |
||
165 | |||
166 | /** |
||
167 | * @param $version Windows number version |
||
168 | * @return string Windows version |
||
169 | */ |
||
170 | private static function getWindowsVersion($version) |
||
184 | |||
185 | } |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: