@@ -164,7 +164,7 @@ |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | - * @param $version Windows number version |
|
167 | + * @param string $version Windows number version |
|
168 | 168 | * @return string Windows version |
169 | 169 | */ |
170 | 170 | private static function getWindowsVersion($version) |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | { |
19 | 19 | if ($pathToData == 'auto') |
20 | 20 | { |
21 | - $pathToData = str_replace('src', 'data', __DIR__) . '/'; |
|
21 | + $pathToData = str_replace('src', 'data', __DIR__).'/'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | if (self::$xmlData == null) |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | $xml = array('Robot', 'Browser', 'Device', 'OS'); |
27 | 27 | $xmlData = array(); |
28 | 28 | foreach ($xml as $name) { |
29 | - $xmlData[$name] = simplexml_load_file($pathToData . strtolower($name) . '.xml'); |
|
29 | + $xmlData[$name] = simplexml_load_file($pathToData.strtolower($name).'.xml'); |
|
30 | 30 | } |
31 | 31 | self::$xmlData = $xmlData; |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - public static function analyse($uaString='UA', $pathToData='auto') |
|
35 | + public static function analyse($uaString = 'UA', $pathToData = 'auto') |
|
36 | 36 | { |
37 | 37 | $ua = $uaString; |
38 | - if($uaString == 'UA') |
|
38 | + if ($uaString == 'UA') |
|
39 | 39 | { |
40 | 40 | $ua = $_SERVER['HTTP_USER_AGENT']; |
41 | 41 | } |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | $detectorResult->uaString = $ua; |
48 | 48 | $ns = '\\EndorphinStudio\\Detector\\'; |
49 | 49 | |
50 | - foreach($xml as $key => $item) |
|
50 | + foreach ($xml as $key => $item) |
|
51 | 51 | { |
52 | - $data = self::analysePart($xml,$key,$ua); |
|
52 | + $data = self::analysePart($xml, $key, $ua); |
|
53 | 53 | $classname = $ns.$key; |
54 | - if($data !== null) |
|
54 | + if ($data !== null) |
|
55 | 55 | { |
56 | 56 | $object = new $classname($data); |
57 | - if($key == 'OS' || $key == 'Browser') |
|
57 | + if ($key == 'OS' || $key == 'Browser') |
|
58 | 58 | { |
59 | 59 | $object->setVersion(self::getVersion($data, $ua)); |
60 | 60 | } |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @param string $uaString User agent |
78 | 78 | * @return \SimpleXMLElement xml element |
79 | 79 | */ |
80 | - private static function analysePart($xmlData,$key,$uaString) |
|
80 | + private static function analysePart($xmlData, $key, $uaString) |
|
81 | 81 | { |
82 | 82 | $data = $xmlData[$key]->data; |
83 | - foreach($data as $xmlItem) |
|
83 | + foreach ($data as $xmlItem) |
|
84 | 84 | { |
85 | 85 | $pattern = '/'.$xmlItem->pattern.'/'; |
86 | - if(preg_match($pattern,$uaString)) |
|
86 | + if (preg_match($pattern, $uaString)) |
|
87 | 87 | { |
88 | 88 | return $xmlItem; |
89 | 89 | } |
@@ -96,21 +96,21 @@ discard block |
||
96 | 96 | * @param string $uaString User agent |
97 | 97 | * @return string Version |
98 | 98 | */ |
99 | - private static function getVersion(\SimpleXMLElement $xmlItem,$uaString) |
|
99 | + private static function getVersion(\SimpleXMLElement $xmlItem, $uaString) |
|
100 | 100 | { |
101 | - if($xmlItem !== null) |
|
101 | + if ($xmlItem !== null) |
|
102 | 102 | { |
103 | - foreach($xmlItem->children() as $node) |
|
103 | + foreach ($xmlItem->children() as $node) |
|
104 | 104 | { |
105 | - if($node->getName() == 'versionPattern') |
|
105 | + if ($node->getName() == 'versionPattern') |
|
106 | 106 | { |
107 | 107 | $vPattern = $node->__toString(); |
108 | - $version = '/' . $vPattern . '(\/| )[\w-._]{1,15}/'; |
|
108 | + $version = '/'.$vPattern.'(\/| )[\w-._]{1,15}/'; |
|
109 | 109 | $uaString = str_replace(' NT', '', $uaString); |
110 | 110 | if (preg_match($version, $uaString)) { |
111 | 111 | preg_match($version, $uaString, $v); |
112 | 112 | $version = $v[0]; |
113 | - $version = preg_replace('/' . $vPattern . '/', '', $version); |
|
113 | + $version = preg_replace('/'.$vPattern.'/', '', $version); |
|
114 | 114 | $version = str_replace(';', '', $version); |
115 | 115 | $version = str_replace(' ', '', $version); |
116 | 116 | $version = str_replace('/', '', $version); |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | private static function checkRules(DetectorResult $result) |
155 | 155 | { |
156 | 156 | $Rules = DetectorRule::loadRulesFromFile(); |
157 | - foreach($Rules as $rule) |
|
157 | + foreach ($Rules as $rule) |
|
158 | 158 | { |
159 | 159 | $objectType = $rule->getObjectType(); |
160 | 160 | $objectProperty = $rule->getObjectProperty(); |
161 | 161 | $targetType = $rule->getTargetType(); |
162 | 162 | $targetValue = $rule->isTargetValue(); |
163 | 163 | $func = 'get'.$objectProperty; |
164 | - if($result->$objectType !== null) |
|
164 | + if ($result->$objectType !== null) |
|
165 | 165 | { |
166 | 166 | if ($result->$objectType->$func() == $rule->getObjectPropertyValue()) { |
167 | 167 | $result->$targetType = $targetValue; |
@@ -172,4 +172,4 @@ discard block |
||
172 | 172 | return $result; |
173 | 173 | } |
174 | 174 | } |
175 | -define('D_NA','N\A'); |
|
175 | +define('D_NA', 'N\A'); |