Completed
Push — master ( 9156a4...0ac3a5 )
by Angus
04:44
created
application/models/Tracker/Tracker_Sites_Model.php 1 patch
Braces   +36 added lines, -12 removed lines patch added patch discarded remove patch
@@ -125,7 +125,9 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	final public function isValidTitleURL(string $title_url) : bool {
127 127
 		$success = (bool) preg_match($this->titleFormat, $title_url);
128
-		if(!$success) log_message('error', "Invalid Title URL ({$this->site}): {$title_url}");
128
+		if(!$success) {
129
+			log_message('error', "Invalid Title URL ({$this->site}): {$title_url}");
130
+		}
129 131
 		return $success;
130 132
 	}
131 133
 
@@ -139,7 +141,9 @@  discard block
 block discarded – undo
139 141
 	 */
140 142
 	final public function isValidChapter(string $chapter) : bool {
141 143
 		$success = (bool) preg_match($this->chapterFormat, $chapter);
142
-		if(!$success) log_message('error', "Invalid Chapter ({$this->site}): {$chapter}");
144
+		if(!$success) {
145
+			log_message('error', "Invalid Chapter ({$this->site}): {$chapter}");
146
+		}
143 147
 		return $success;
144 148
 	}
145 149
 
@@ -168,14 +172,20 @@  discard block
 block discarded – undo
168 172
 			//curl_setopt($ch, CURLOPT_VERBOSE, 1);
169 173
 			curl_setopt($ch, CURLOPT_HEADER, 1);
170 174
 
171
-			if($follow_redirect)        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
175
+			if($follow_redirect) {
176
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
177
+			}
172 178
 
173 179
 			if($cookies = $this->cache->get("cloudflare_{$this->site}")) {
174 180
 				$cookie_string .= "; {$cookies}";
175 181
 			}
176 182
 
177
-			if(!empty($cookie_string))  curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
178
-			if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
183
+			if(!empty($cookie_string)) {
184
+				curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
185
+			}
186
+			if(!empty($cookiejar_path)) {
187
+				curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
188
+			}
179 189
 
180 190
 			//Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff.
181 191
 			curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
@@ -206,7 +216,9 @@  discard block
 block discarded – undo
206 216
 			$body        = substr($response, $header_size);
207 217
 			curl_close($ch);
208 218
 
209
-			if($status_code === 503) $refresh = $this->handleCloudFlare($url, $body);
219
+			if($status_code === 503) {
220
+				$refresh = $this->handleCloudFlare($url, $body);
221
+			}
210 222
 		}
211 223
 
212 224
 		return [
@@ -312,7 +324,9 @@  discard block
 block discarded – undo
312 324
 								'nodes_chapter' => $nodes_chapter->item(0)
313 325
 							];
314 326
 
315
-							if(is_callable($extraCall)) $extraCall($xpath, $returnData);
327
+							if(is_callable($extraCall)) {
328
+								$extraCall($xpath, $returnData);
329
+							}
316 330
 
317 331
 							return $returnData;
318 332
 						} else {
@@ -326,7 +340,9 @@  discard block
 block discarded – undo
326 340
 						$noChaptersCall($data, $xpath, $returnData);
327 341
 
328 342
 						if(is_array($returnData)) {
329
-							if(is_callable($extraCall) && is_array($returnData)) $extraCall($xpath, $returnData);
343
+							if(is_callable($extraCall) && is_array($returnData)) {
344
+								$extraCall($xpath, $returnData);
345
+							}
330 346
 						} else {
331 347
 							log_message('error', "{$this->site} : {$title_url} | canHaveNoChapters set, but doesn't match possible checks! XPath is probably broken.");
332 348
 						}
@@ -461,8 +477,12 @@  discard block
 block discarded – undo
461 477
 		$status = FALSE;
462 478
 
463 479
 		//Make sure we have a volume element
464
-		if(count($oldChapterSegments) === 1) array_unshift($oldChapterSegments, 'v0');
465
-		if(count($newChapterSegments) === 1) array_unshift($newChapterSegments, 'v0');
480
+		if(count($oldChapterSegments) === 1) {
481
+			array_unshift($oldChapterSegments, 'v0');
482
+		}
483
+		if(count($newChapterSegments) === 1) {
484
+			array_unshift($newChapterSegments, 'v0');
485
+		}
466 486
 
467 487
 		$oldCount = count($oldChapterSegments);
468 488
 		$newCount = count($newChapterSegments);
@@ -475,8 +495,12 @@  discard block
 block discarded – undo
475 495
 				$newVolume = substr(array_shift($newChapterSegments), 1);
476 496
 
477 497
 				//Forcing volume to 0 as TBD might not be the latest (although it can be, but that is covered by other checks)
478
-				if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $oldVolume = 0;
479
-				if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $newVolume = 0;
498
+				if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) {
499
+					$oldVolume = 0;
500
+				}
501
+				if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) {
502
+					$newVolume = 0;
503
+				}
480 504
 
481 505
 				$oldVolume = floatval($oldVolume);
482 506
 				$newVolume = floatval($newVolume);
Please login to merge, or discard this patch.