Completed
Push — 3.0.0 ( ceb3bc...0dd3e2 )
by Serhii
02:19
created
src/Device.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@
 block discarded – undo
25 25
         {
26 26
             $this->Name = 'Desktop';
27 27
             $this->Type = 'desktop';
28
-        }
29
-        else
28
+        } else
30 29
         {
31 30
             parent::__construct($xmlData);
32 31
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
      */
22 22
     public function __construct(\SimpleXMLElement $xmlData)
23 23
     {
24
-        if($xmlData === null || $xmlData->getName() == 'null')
24
+        if ($xmlData === null || $xmlData->getName() == 'null')
25 25
         {
26 26
             parent::__construct($xmlData);
27 27
 
Please login to merge, or discard this patch.
src/OS.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function __construct(\SimpleXMLElement $xmlData)
23 23
     {
24 24
         parent::__construct($xmlData);
25
-        if($xmlData !== null)
25
+        if ($xmlData !== null)
26 26
         {
27 27
             foreach ($xmlData->children() as $child) {
28 28
                 switch ($child->getName()) {
@@ -46,6 +46,6 @@  discard block
 block discarded – undo
46 46
 
47 47
 }
48 48
 
49
-define('UNX','unix');
50
-define('WIN','windows');
51
-define('MC','mac');
49
+define('UNX', 'unix');
50
+define('WIN', 'windows');
51
+define('MC', 'mac');
Please login to merge, or discard this patch.
src/Data.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
     {
73 73
         parent::__construct($xmlData);
74 74
 
75
-        if($xmlData !== null)
75
+        if ($xmlData !== null)
76 76
         {
77 77
             foreach ($xmlData->children() as $child)
78 78
             {
Please login to merge, or discard this patch.
src/Robot.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,19 +72,19 @@
 block discarded – undo
72 72
     {
73 73
         parent::__construct($xmlData);
74 74
 
75
-        if($xmlData !== null)
75
+        if ($xmlData !== null)
76 76
         {
77 77
             foreach ($xmlData->children() as $child)
78 78
             {
79 79
                 $name = $child->getName();
80 80
                 $val = $child->__toString();
81
-                if($name != 'id' && $name != 'pattern' && $name != 'SearchEngine')
81
+                if ($name != 'id' && $name != 'pattern' && $name != 'SearchEngine')
82 82
                 {
83 83
                     $this->$name = $val;
84 84
                 }
85
-                if($name == 'SearchEngine')
85
+                if ($name == 'SearchEngine')
86 86
                 {
87
-                    if($val == 'true')
87
+                    if ($val == 'true')
88 88
                     {
89 89
                         $this->setSearchEngine(true);
90 90
                     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,9 +87,9 @@
 block discarded – undo
87 87
                     if($val == 'true')
88 88
                     {
89 89
                         $this->setSearchEngine(true);
90
+                    } else {
91
+                                            $this->setSearchEngine(false);
90 92
                     }
91
-                    else
92
-                        $this->setSearchEngine(false);
93 93
                 }
94 94
             }
95 95
         }
Please login to merge, or discard this patch.
src/DetectorRule.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 
105 105
     public function __construct(\SimpleXMLElement $xmlData)
106 106
     {
107
-        if($xmlData !== null)
107
+        if ($xmlData !== null)
108 108
         {
109 109
             foreach ($xmlData->children() as $child)
110 110
             {
111 111
                 $name = $child->getName();
112 112
                 $val = $child->__toString();
113
-                if($name != 'TargetValue')
113
+                if ($name != 'TargetValue')
114 114
                 {
115 115
                     $this->$name = $val;
116 116
                 }
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public static function loadRulesFromFile()
127 127
     {
128
-        $path = str_replace('src','data',__DIR__).'/rules/';
128
+        $path = str_replace('src', 'data', __DIR__).'/rules/';
129 129
         $files = scandir($path);
130 130
         $rules = array();
131
-        foreach($files as $file)
131
+        foreach ($files as $file)
132 132
         {
133
-            if($file != '.' && $file != '..')
133
+            if ($file != '.' && $file != '..')
134 134
             {
135 135
                 $xmlObj = simplexml_load_file($path.$file);
136
-                foreach($xmlObj->children() as $rule)
136
+                foreach ($xmlObj->children() as $rule)
137 137
                 {
138 138
                     $rules[] = new self($rule);
139 139
                 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -113,9 +113,9 @@
 block discarded – undo
113 113
                 if($name != 'TargetValue')
114 114
                 {
115 115
                     $this->$name = $val;
116
+                } else {
117
+                                    $this->$name = filter_var($val, FILTER_VALIDATE_BOOLEAN);
116 118
                 }
117
-                else
118
-                    $this->$name = filter_var($val, FILTER_VALIDATE_BOOLEAN);
119 119
             }
120 120
         }
121 121
     }
Please login to merge, or discard this patch.
src/Detector.php 2 patches
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@  discard block
 block discarded – undo
58 58
                 {
59 59
                     $object->setVersion(self::getVersion($data, $ua));
60 60
                 }
61
-            }
62
-            else
61
+            } else
63 62
             {
64 63
                 $object = $classname::initEmpty();
65 64
             }
@@ -152,10 +151,11 @@  discard block
 block discarded – undo
152 151
             '10.0' => '10'
153 152
         );
154 153
 
155
-        if(array_key_exists(strval($version),$versions))
156
-            return $versions[strval($version)];
157
-        else
158
-            return D_NA;
154
+        if(array_key_exists(strval($version),$versions)) {
155
+                    return $versions[strval($version)];
156
+        } else {
157
+                    return D_NA;
158
+        }
159 159
     }
160 160
 
161 161
     /**
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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')
35
+    public static function analyse($uaString = 'UA')
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,20 +47,20 @@  discard block
 block discarded – undo
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
                 }
61
-                if($key == 'Robot')
61
+                if ($key == 'Robot')
62 62
                 {
63
-                    if($object->getName() != D_NA)
63
+                    if ($object->getName() != D_NA)
64 64
                     {
65 65
                         $detectorResult->isBot = true;
66 66
                     }
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
      * @param string $uaString User agent
85 85
      * @return \SimpleXMLElement xml element
86 86
      */
87
-    private static function analysePart($xmlData,$key,$uaString)
87
+    private static function analysePart($xmlData, $key, $uaString)
88 88
     {
89 89
         $data = $xmlData[$key]->data;
90
-        foreach($data as $xmlItem)
90
+        foreach ($data as $xmlItem)
91 91
         {
92 92
             $pattern = '/'.$xmlItem->pattern.'/';
93
-            if(preg_match($pattern,$uaString))
93
+            if (preg_match($pattern, $uaString))
94 94
             {
95 95
                 return $xmlItem;
96 96
             }
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
      * @param string $uaString User agent
104 104
      * @return string Version
105 105
      */
106
-    private static function getVersion(\SimpleXMLElement $xmlItem,$uaString)
106
+    private static function getVersion(\SimpleXMLElement $xmlItem, $uaString)
107 107
     {
108
-        if($xmlItem !== null)
108
+        if ($xmlItem !== null)
109 109
         {
110
-            foreach($xmlItem->children() as $node)
110
+            foreach ($xmlItem->children() as $node)
111 111
             {
112
-                if($node->getName() == 'versionPattern')
112
+                if ($node->getName() == 'versionPattern')
113 113
                 {
114 114
                     $vPattern = $node->__toString();
115
-                    $version = '/' . $vPattern . '(\/| )[\w-._]{1,15}/';
115
+                    $version = '/'.$vPattern.'(\/| )[\w-._]{1,15}/';
116 116
                     $uaString = str_replace(' NT', '', $uaString);
117 117
                     if (preg_match($version, $uaString)) {
118 118
                         preg_match($version, $uaString, $v);
119 119
                         $version = $v[0];
120
-                        $version = preg_replace('/' . $vPattern . '/', '', $version);
120
+                        $version = preg_replace('/'.$vPattern.'/', '', $version);
121 121
                         $version = str_replace(';', '', $version);
122 122
                         $version = str_replace(' ', '', $version);
123 123
                         $version = str_replace('/', '', $version);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             '10.0' => '10'
160 160
         );
161 161
 
162
-        if(array_key_exists(strval($version),$versions))
162
+        if (array_key_exists(strval($version), $versions))
163 163
             return $versions[strval($version)];
164 164
         else
165 165
             return D_NA;
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
     private static function checkRules(DetectorResult $result)
173 173
     {
174 174
         $Rules = DetectorRule::loadRulesFromFile();
175
-        foreach($Rules as $rule)
175
+        foreach ($Rules as $rule)
176 176
         {
177 177
             $objectType = $rule->getObjectType();
178 178
             $objectProperty = $rule->getObjectProperty();
179 179
             $targetType = $rule->getTargetType();
180 180
             $targetValue = $rule->isTargetValue();
181 181
             $func = 'get'.$objectProperty;
182
-            if($result->$objectType !== null)
182
+            if ($result->$objectType !== null)
183 183
             {
184 184
                 if ($result->$objectType->$func() == $rule->getObjectPropertyValue()) {
185 185
                     $result->$targetType = $targetValue;
@@ -190,4 +190,4 @@  discard block
 block discarded – undo
190 190
         return $result;
191 191
     }
192 192
 }
193
-define('D_NA','N\A');
193
+define('D_NA', 'N\A');
Please login to merge, or discard this patch.