@@ -544,14 +544,12 @@ |
||
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 | } |
@@ -21,7 +21,9 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -12,11 +12,17 @@ discard block |
||
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 |
||
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 | } |