Test Failed
Pull Request — master (#85)
by Gabriel
02:58
created
src/ScriptedAgentDetector.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
75 75
         self::$scriptedAgent->setInfoURL(ScriptedAgent::UNKNOWN);
76 76
 
77 77
         foreach (self::$robotsList as $robotName) {
78
-            $funcName = self::FUNC_PREFIX . $robotName;
78
+            $funcName = self::FUNC_PREFIX.$robotName;
79 79
 
80 80
             if (self::$funcName()) {
81 81
                 return true;
Please login to merge, or discard this patch.
src/ScriptedAgent.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function setName($name)
102 102
     {
103
-        $this->name = (string)$name;
103
+        $this->name = (string) $name;
104 104
     }
105 105
 
106 106
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function setType($type)
128 128
     {
129
-        $this->type = (string)$type;
129
+        $this->type = (string) $type;
130 130
     }
131 131
 
132 132
     /**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function setInfoURL($url)
154 154
     {
155
-        $this->url = (string)$url;
155
+        $this->url = (string) $url;
156 156
     }
157 157
 
158 158
     /**
Please login to merge, or discard this patch.
src/Browser.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function setName($name)
111 111
     {
112
-        $this->name = (string)$name;
112
+        $this->name = (string) $name;
113 113
         return $this;
114 114
     }
115 115
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function setVersion($version)
148 148
     {
149
-        $this->version = (string)$version;
149
+        $this->version = (string) $version;
150 150
         return $this;
151 151
     }
152 152
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             (stripos($ua, 'Chrome/51.0.2704.103') !== false && !isset($_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS']) && stristr($_SERVER['HTTP_ACCEPT_LANGUAGE'], "ru-RU") !== false) //ICQ Preview
213 213
         ) {
214 214
             $scriptedAgent = new ScriptedAgent($ua);
215
-            if ($scriptedAgent->getName()==ScriptedAgent::UNKNOWN) {
215
+            if ($scriptedAgent->getName() == ScriptedAgent::UNKNOWN) {
216 216
                 return false;
217 217
             } else {
218 218
                 return $scriptedAgent;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public function setIsChromeFrame($isChromeFrame)
230 230
     {
231
-        $this->isChromeFrame = (bool)$isChromeFrame;
231
+        $this->isChromeFrame = (bool) $isChromeFrame;
232 232
         return $this;
233 233
     }
234 234
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      */
261 261
     public function setIsWebkit($isWebkit)
262 262
     {
263
-        $this->isWebkit = (bool)$isWebkit;
263
+        $this->isWebkit = (bool) $isWebkit;
264 264
         return $this;
265 265
     }
266 266
 
Please login to merge, or discard this patch.
scripts/fetchEdgeVersions/ChangeWindows.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -86,6 +86,9 @@  discard block
 block discarded – undo
86 86
         return $siblingVersions;
87 87
     }
88 88
 
89
+    /**
90
+     * @param string $content
91
+     */
89 92
     private static function fetchEdgeVersion($content)
90 93
     {
91 94
         preg_match('/<h4[^>]*> *Edge ([\d\.]*) *<\/h4>/', $content, $edge);
@@ -97,6 +100,10 @@  discard block
 block discarded – undo
97 100
         return null;
98 101
     }
99 102
 
103
+    /**
104
+     * @param string $edgeHtml
105
+     * @param string $edge
106
+     */
100 107
     private static function writeEdgeVersion($edgeHtml, $edge)
101 108
     {
102 109
         $file = __DIR__ . '/../../src/edgeVersionMap.php';
@@ -120,6 +127,9 @@  discard block
 block discarded – undo
120 127
         }
121 128
     }
122 129
 
130
+    /**
131
+     * @param string $content
132
+     */
123 133
     private static function fetchSiblingVersions($content)
124 134
     {
125 135
         if (!$content) throw new Exception(self::$errors['could_not_fetch_page']);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     public static function fetchVersions()
20 20
     {
21
-        $windowsVersions = json_decode(file_get_contents(__DIR__ . '/windowsVersions.json'), true);
21
+        $windowsVersions = json_decode(file_get_contents(__DIR__.'/windowsVersions.json'), true);
22 22
         if (!count($windowsVersions)) {
23 23
             $currentVersion = explode('.', self::fetchCurrentVersion(), 2);
24 24
             if (!isset($currentVersion[0])) throw new Exception(self::$errors['invalid_version']);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     private static function writeWindowsVersions($windowsVersions)
62 62
     {
63 63
         ksort($windowsVersions);
64
-        file_put_contents(__DIR__ . '/windowsVersions.json', json_encode($windowsVersions, JSON_PRETTY_PRINT));
64
+        file_put_contents(__DIR__.'/windowsVersions.json', json_encode($windowsVersions, JSON_PRETTY_PRINT));
65 65
     }
66 66
 
67 67
     private static function fetchCurrentVersion()
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 
100 100
     private static function writeEdgeVersion($edgeHtml, $edge)
101 101
     {
102
-        $file = __DIR__ . '/../../src/edgeVersionMap.php';
102
+        $file = __DIR__.'/../../src/edgeVersionMap.php';
103 103
         $currentVersions = require $file;
104 104
         if (!isset($currentVersions[$edgeHtml])) {
105 105
             $currentVersions[$edgeHtml] = $edge;
106 106
             ksort($currentVersions);
107 107
             $content = '';
108 108
             foreach ($currentVersions as $edgeHtml => $edge) {
109
-                $content .= "    '{$edgeHtml}' => '{$edge}'," . PHP_EOL;
109
+                $content .= "    '{$edgeHtml}' => '{$edge}',".PHP_EOL;
110 110
             }
111 111
             $data = <<<PHP
112 112
 <?php
Please login to merge, or discard this patch.
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,7 +21,9 @@  discard block
 block discarded – undo
21 21
         $windowsVersions = json_decode(file_get_contents(__DIR__ . '/windowsVersions.json'), true);
22 22
         if (!count($windowsVersions)) {
23 23
             $currentVersion = explode('.', self::fetchCurrentVersion(), 2);
24
-            if (!isset($currentVersion[0])) throw new Exception(self::$errors['invalid_version']);
24
+            if (!isset($currentVersion[0])) {
25
+                throw new Exception(self::$errors['invalid_version']);
26
+            }
25 27
             $windowsVersions = self::fetchVersion($windowsVersions, $currentVersion[0]);
26 28
             self::writeWindowsVersions($windowsVersions);
27 29
         } else {
@@ -67,13 +69,21 @@  discard block
 block discarded – undo
67 69
     private static function fetchCurrentVersion()
68 70
     {
69 71
         $content = file_get_contents('https://changewindows.org/filter/pc/all/current/month/true');
70
-        if (!$content) throw new Exception(self::$errors['could_not_fetch_version']);
72
+        if (!$content) {
73
+            throw new Exception(self::$errors['could_not_fetch_version']);
74
+        }
71 75
         $content = explode('class="timeline"', $content, 2);
72
-        if (!isset($content[1])) throw new Exception(self::$errors['could_not_fetch_version']);
76
+        if (!isset($content[1])) {
77
+            throw new Exception(self::$errors['could_not_fetch_version']);
78
+        }
73 79
         $content = explode('build"', $content[1], 2);
74
-        if (!isset($content[1])) throw new Exception(self::$errors['could_not_fetch_version']);
80
+        if (!isset($content[1])) {
81
+            throw new Exception(self::$errors['could_not_fetch_version']);
82
+        }
75 83
         preg_match("/(\d*\.\d*)<\/div>/", $content[1], $matches);
76
-        if (!isset($matches[1])) throw new Exception(self::$errors['could_not_fetch_version']);
84
+        if (!isset($matches[1])) {
85
+            throw new Exception(self::$errors['could_not_fetch_version']);
86
+        }
77 87
         return $matches[1];
78 88
     }
79 89
 
@@ -122,15 +132,25 @@  discard block
 block discarded – undo
122 132
 
123 133
     private static function fetchSiblingVersions($content)
124 134
     {
125
-        if (!$content) throw new Exception(self::$errors['could_not_fetch_page']);
135
+        if (!$content) {
136
+            throw new Exception(self::$errors['could_not_fetch_page']);
137
+        }
126 138
         $content = explode('build-sidebar', $content, 2);
127
-        if (!isset($content[1])) throw new Exception(self::$errors['could_not_fetch_page']);
139
+        if (!isset($content[1])) {
140
+            throw new Exception(self::$errors['could_not_fetch_page']);
141
+        }
128 142
         $content = explode('fa-angle-left', $content[1]);
129
-        if (!isset($content[1])) throw new Exception(self::$errors['could_not_fetch_page']);
143
+        if (!isset($content[1])) {
144
+            throw new Exception(self::$errors['could_not_fetch_page']);
145
+        }
130 146
         $content = explode('fa-angle-right', $content[1]);
131
-        if (!isset($content[0])) throw new Exception(self::$errors['could_not_fetch_page']);
147
+        if (!isset($content[0])) {
148
+            throw new Exception(self::$errors['could_not_fetch_page']);
149
+        }
132 150
         preg_match_all("/> *(\d+) *</", $content[0], $matches);
133
-        if (!isset($matches[1])) throw new Exception(self::$errors['could_not_fetch_page']);
151
+        if (!isset($matches[1])) {
152
+            throw new Exception(self::$errors['could_not_fetch_page']);
153
+        }
134 154
         return $matches[1];
135 155
     }
136 156
 }
Please login to merge, or discard this patch.
src/BrowserDetector.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         self::checkWebkit();
163 163
 
164 164
         foreach (self::$browsersList as $browserName) {
165
-            $funcName = self::FUNC_PREFIX . $browserName;
165
+            $funcName = self::FUNC_PREFIX.$browserName;
166 166
 
167 167
             if (self::$funcName()) {
168 168
                 return true;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
             $aresult = explode('Version/10.', self::$userAgentString);
265 265
             if (isset($aresult[1])) {
266 266
                 $aversion = explode(' ', $aresult[1]);
267
-                self::$browser->setVersion('10.' . $aversion[0]);
267
+                self::$browser->setVersion('10.'.$aversion[0]);
268 268
             }
269 269
             self::$browser->setName(Browser::BLACKBERRY);
270 270
             return true;
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
     {
539 539
         if (stripos(self::$userAgentString, 'Edge') !== false) {
540 540
             preg_match('/Edge[\\/ \\(]([a-zA-Z\\d\\.]*)/i', self::$userAgentString, $matches);
541
-            if (sizeof($matches)>1)
541
+            if (sizeof($matches) > 1)
542 542
             {
543 543
                 if (isset(self::$edgeHTML[$matches[1]]))
544 544
                 {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -544,14 +544,12 @@
 block discarded – undo
544 544
                 {
545 545
                     self::$browser->setName(Browser::EDGE);
546 546
                     self::$browser->setVersion(self::$edgeHTML[$matches[1]]);
547
-                }
548
-                else
547
+                } else
549 548
                 {
550 549
                     self::$browser->setName(Browser::EDGE_HTML);
551 550
                     self::$browser->setVersion($matches[1]);
552 551
                 }
553
-            }
554
-            else
552
+            } else
555 553
             {
556 554
                 self::$browser->setName(Browser::EDGE);
557 555
             }
Please login to merge, or discard this patch.
scripts/fetchEdgeVersions/Wikipedia.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     {
27 27
         $lines = array_slice(array_filter(
28 28
             explode(PHP_EOL, $content),
29
-            function ($val) { return trim($val) && strpos($val, '|') === 0; }
29
+            function($val) { return trim($val) && strpos($val, '|') === 0; }
30 30
         ), 0, 2);
31 31
 
32 32
         preg_match("/{[^}{]*Version[^}{]*\| ?([\d\.]+)}/", $lines[0], $edgeVersion);
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
     private static function writeEdgeVersions($versions)
42 42
     {
43
-        $file = __DIR__ . '/../../src/edgeVersionMap.php';
43
+        $file = __DIR__.'/../../src/edgeVersionMap.php';
44 44
         $currentVersions = require $file;
45 45
 
46 46
         foreach ($versions as $version) {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
         $content = '';
52 52
         foreach ($currentVersions as $edgeHtml => $edge) {
53
-            $content .= "    '{$edgeHtml}' => '{$edge}'," . PHP_EOL;
53
+            $content .= "    '{$edgeHtml}' => '{$edge}',".PHP_EOL;
54 54
         }
55 55
         $data = <<<PHP
56 56
 <?php
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,11 +12,17 @@  discard block
 block discarded – undo
12 12
     public static function fetch()
13 13
     {
14 14
         $content = file_get_contents(self::URL);
15
-        if (!$content) throw new Exception(self::$errors['fetch_error']);
15
+        if (!$content) {
16
+            throw new Exception(self::$errors['fetch_error']);
17
+        }
16 18
         $content = explode('===Release history===', $content);
17
-        if (!isset($content[1])) throw new Exception(self::$errors['parse_error']);
19
+        if (!isset($content[1])) {
20
+            throw new Exception(self::$errors['parse_error']);
21
+        }
18 22
         $table = explode('|-', $content[1]);
19
-        if (!isset($table[1])) throw new Exception(self::$errors['parse_error']);
23
+        if (!isset($table[1])) {
24
+            throw new Exception(self::$errors['parse_error']);
25
+        }
20 26
         $table = array_slice($table, 1);
21 27
         $versions = array_map(array('Wikipedia', 'extractVersion'), $table);
22 28
         self::writeEdgeVersions($versions);
@@ -32,8 +38,12 @@  discard block
 block discarded – undo
32 38
         preg_match("/{[^}{]*Version[^}{]*\| ?([\d\.]+)}/", $lines[0], $edgeVersion);
33 39
         preg_match("/\| *(\d*\.\d*)/", $lines[1], $edgeHtmlVersion);
34 40
 
35
-        if (!isset($edgeVersion[1])) throw new Exception(self::$errors['parse_error']);
36
-        if (!isset($edgeHtmlVersion[1])) throw new Exception(self::$errors['parse_error']);
41
+        if (!isset($edgeVersion[1])) {
42
+            throw new Exception(self::$errors['parse_error']);
43
+        }
44
+        if (!isset($edgeHtmlVersion[1])) {
45
+            throw new Exception(self::$errors['parse_error']);
46
+        }
37 47
 
38 48
         return array($edgeHtmlVersion[1], $edgeVersion[1]);
39 49
     }
Please login to merge, or discard this patch.
scripts/fetchEdgeVersions/index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__ . '/ChangeWindows.php';
4
-require_once __DIR__ . '/Wikipedia.php';
3
+require_once __DIR__.'/ChangeWindows.php';
4
+require_once __DIR__.'/Wikipedia.php';
5 5
 
6 6
 Wikipedia::fetch();
7 7
 ChangeWindows::fetchVersions();
Please login to merge, or discard this patch.