Completed
Branch 3.0.0 (5cf6f2)
by Serhii
03:39 queued 01:06
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/DetectorRule.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  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
                 switch ($child->getName())
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                         break;
124 124
                     case 'targetProperty':
125 125
                         $boolVal = $child->__toString();
126
-                        if($boolVal == 'true')
126
+                        if ($boolVal == 'true')
127 127
                         {
128 128
                             $this->TargetValue = true;
129 129
                         }
@@ -142,15 +142,15 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public static function loadRulesFromFile()
144 144
     {
145
-        $path = str_replace('src','data',__DIR__).'/rules/';
145
+        $path = str_replace('src', 'data', __DIR__).'/rules/';
146 146
         $files = scandir($path);
147 147
         $rules = array();
148
-        foreach($files as $file)
148
+        foreach ($files as $file)
149 149
         {
150
-            if($file != '.' && $file != '..')
150
+            if ($file != '.' && $file != '..')
151 151
             {
152 152
                 $xmlObj = simplexml_load_file($path.$file);
153
-                foreach($xmlObj->children() as $rule)
153
+                foreach ($xmlObj->children() as $rule)
154 154
                 {
155 155
                     $rules[] = new self($rule);
156 156
                 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,8 +126,7 @@
 block discarded – undo
126 126
                         if($boolVal == 'true')
127 127
                         {
128 128
                             $this->TargetValue = true;
129
-                        }
130
-                        else
129
+                        } else
131 130
                         {
132 131
                             $this->TargetValue = false;
133 132
                         }
Please login to merge, or discard this patch.
src/Detector.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,8 +98,7 @@
 block discarded – undo
98 98
                 {
99 99
                     $object->setVersion(self::getVersion($result, $ua));
100 100
                 }
101
-            }
102
-            else
101
+            } else
103 102
             {
104 103
                 $object = $classname::initEmpty();
105 104
             }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -52,26 +52,26 @@  discard block
 block discarded – undo
52 52
      * Detector constructor.
53 53
      * @param string $pathToData Path to directory with xml data files
54 54
      */
55
-    private function __construct($pathToData='auto')
55
+    private function __construct($pathToData = 'auto')
56 56
     {
57
-        if($pathToData == 'auto')
57
+        if ($pathToData == 'auto')
58 58
         {
59
-            $this->setPathToData(str_replace('src','data',__DIR__).'/');
59
+            $this->setPathToData(str_replace('src', 'data', __DIR__).'/');
60 60
         }
61 61
 
62
-        $xml = array('Robot','Browser','Device','OS');
62
+        $xml = array('Robot', 'Browser', 'Device', 'OS');
63 63
         $xmlData = array();
64
-        foreach($xml as $name)
64
+        foreach ($xml as $name)
65 65
         {
66 66
             $xmlData[$name] = simplexml_load_file($this->getPathToData().strtolower($name).'.xml');
67 67
         }
68 68
         $this->setXmlData($xmlData);
69 69
     }
70 70
 
71
-    public static function analyse($uaString='UA', $pathToData='auto')
71
+    public static function analyse($uaString = 'UA', $pathToData = 'auto')
72 72
     {
73 73
         $ua = $uaString;
74
-        if($uaString == 'UA')
74
+        if ($uaString == 'UA')
75 75
         {
76 76
             $ua = $_SERVER['HTTP_USER_AGENT'];
77 77
         }
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
         $detectorResult->uaString = $ua;
84 84
         $ns = '\\EndorphinStudio\\Detector\\';
85 85
 
86
-        foreach($xml as $key => $item)
86
+        foreach ($xml as $key => $item)
87 87
         {
88
-            $data = self::analysePart($xml,$key,$ua);
88
+            $data = self::analysePart($xml, $key, $ua);
89 89
             $classname = $ns.$key;
90
-            if($data !== null)
90
+            if ($data !== null)
91 91
             {
92 92
                 $object = new $classname($data);
93
-                if($key == 'OS' || $key == 'Browser')
93
+                if ($key == 'OS' || $key == 'Browser')
94 94
                 {
95 95
                     $object->setVersion(self::getVersion($data, $ua));
96 96
                 }
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
      * @param string $uaString User agent
114 114
      * @return \SimpleXMLElement xml element
115 115
      */
116
-    private static function analysePart($xmlData,$key,$uaString)
116
+    private static function analysePart($xmlData, $key, $uaString)
117 117
     {
118 118
         $data = $xmlData[$key]->data;
119
-        foreach($data as $xmlItem)
119
+        foreach ($data as $xmlItem)
120 120
         {
121 121
             $pattern = '/'.$xmlItem->pattern.'/';
122
-            if(preg_match($pattern,$uaString))
122
+            if (preg_match($pattern, $uaString))
123 123
             {
124 124
                 return $xmlItem;
125 125
             }
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
      * @param string $uaString User agent
133 133
      * @return string Version
134 134
      */
135
-    private static function getVersion(\SimpleXMLElement $xmlItem,$uaString)
135
+    private static function getVersion(\SimpleXMLElement $xmlItem, $uaString)
136 136
     {
137
-        if($xmlItem !== null)
137
+        if ($xmlItem !== null)
138 138
         {
139
-            foreach($xmlItem->children() as $node)
139
+            foreach ($xmlItem->children() as $node)
140 140
             {
141
-                if($node->getName() == 'versionPattern')
141
+                if ($node->getName() == 'versionPattern')
142 142
                 {
143 143
                     $vPattern = $node->__toString();
144
-                    $version = '/' . $vPattern . '(\/| )[\w-._]{1,15}/';
144
+                    $version = '/'.$vPattern.'(\/| )[\w-._]{1,15}/';
145 145
                     $uaString = str_replace(' NT', '', $uaString);
146 146
                     if (preg_match($version, $uaString)) {
147 147
                         preg_match($version, $uaString, $v);
148 148
                         $version = $v[0];
149
-                        $version = preg_replace('/' . $vPattern . '/', '', $version);
149
+                        $version = preg_replace('/'.$vPattern.'/', '', $version);
150 150
                         $version = str_replace(';', '', $version);
151 151
                         $version = str_replace(' ', '', $version);
152 152
                         $version = str_replace('/', '', $version);
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
     private static function checkRules(DetectorResult $result)
191 191
     {
192 192
         $Rules = DetectorRule::loadRulesFromFile();
193
-        foreach($Rules as $rule)
193
+        foreach ($Rules as $rule)
194 194
         {
195 195
             $objectType = $rule->getObjectType();
196 196
             $objectProperty = $rule->getObjectProperty();
197 197
             $targetType = $rule->getTargetType();
198 198
             $targetValue = $rule->isTargetValue();
199 199
             $func = 'get'.$objectProperty;
200
-            if($result->$objectType !== null)
200
+            if ($result->$objectType !== null)
201 201
             {
202 202
                 if ($result->$objectType->$func() == $rule->getObjectPropertyValue()) {
203 203
                     $result->$targetType = $targetValue;
@@ -208,4 +208,4 @@  discard block
 block discarded – undo
208 208
         return $result;
209 209
     }
210 210
 }
211
-define('D_NA','N\A');
211
+define('D_NA', 'N\A');
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.