Completed
Push — master ( b3c8ed...9e5008 )
by Angus
02:47
created
application/models/Tracker/Tracker_Sites_Model.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed');
2 2
 
3 3
 /**
4 4
  * Class Tracker_Sites_Model
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @param bool   $firstGet
101 101
 	 * @return array|null [title,latest_chapter,last_updated,followed?]
102 102
 	 */
103
-	abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array;
103
+	abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array;
104 104
 
105 105
 	/**
106 106
 	 * Validates given $title_url against titleFormat.
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	final protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE, bool $isPost = FALSE, array $postFields = []) {
146 146
 		$ch = curl_init();
147 147
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
148
-		curl_setopt($ch, CURLOPT_ENCODING , "gzip");
148
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
149 149
 		//curl_setopt($ch, CURLOPT_VERBOSE, 1);
150 150
 		curl_setopt($ch, CURLOPT_HEADER, 1);
151 151
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 		curl_setopt($ch, CURLOPT_URL, $url);
164 164
 
165 165
 		if($isPost) {
166
-			curl_setopt($ch,CURLOPT_POST, count($postFields));
167
-			curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields));
166
+			curl_setopt($ch, CURLOPT_POST, count($postFields));
167
+			curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
168 168
 		}
169 169
 
170 170
 		$response = curl_exec($ch);
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 				$dom = new DOMDocument();
230 230
 				libxml_use_internal_errors(TRUE);
231
-				$dom->loadHTML('<?xml encoding="utf-8" ?>' . $data);
231
+				$dom->loadHTML('<?xml encoding="utf-8" ?>'.$data);
232 232
 				libxml_use_internal_errors(FALSE);
233 233
 
234 234
 				$xpath = new DOMXPath($dom);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				$nodes_row   = $xpath->query($node_row_string);
237 237
 				if($nodes_title->length === 1 && $nodes_row->length === 1) {
238 238
 					$firstRow      = $nodes_row->item(0);
239
-					$nodes_latest  = $xpath->query($node_latest_string,  $firstRow);
239
+					$nodes_latest  = $xpath->query($node_latest_string, $firstRow);
240 240
 
241 241
 					if($node_chapter_string !== '') {
242 242
 						$nodes_chapter = $xpath->query($node_chapter_string, $firstRow);
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 		$chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/)
425 425
 		return [
426 426
 			'url'    => "{$this->baseURL}/read/{$title_url}/{$chapter}/",
427
-			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
427
+			'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/
428 428
 		];
429 429
 	}
430 430
 
431
-	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array {
431
+	public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array {
432 432
 		$titleData = [];
433 433
 
434 434
 		$jsonURL = "{$this->baseURL}/api/reader/comic/stub/{$title_url}/format/json";
Please login to merge, or discard this patch.
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -112,7 +112,9 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	final public function isValidTitleURL(string $title_url) : bool {
114 114
 		$success = (bool) preg_match($this->titleFormat, $title_url);
115
-		if(!$success) log_message('error', "Invalid Title URL ({$this->site}): {$title_url}");
115
+		if(!$success) {
116
+			log_message('error', "Invalid Title URL ({$this->site}): {$title_url}");
117
+		}
116 118
 		return $success;
117 119
 	}
118 120
 
@@ -126,7 +128,9 @@  discard block
 block discarded – undo
126 128
 	 */
127 129
 	final public function isValidChapter(string $chapter) : bool {
128 130
 		$success = (bool) preg_match($this->chapterFormat, $chapter);
129
-		if(!$success) log_message('error', "Invalid Chapter ({$this->site}): {$chapter}");
131
+		if(!$success) {
132
+			log_message('error', "Invalid Chapter ({$this->site}): {$chapter}");
133
+		}
130 134
 		return $success;
131 135
 	}
132 136
 
@@ -149,10 +153,16 @@  discard block
 block discarded – undo
149 153
 		//curl_setopt($ch, CURLOPT_VERBOSE, 1);
150 154
 		curl_setopt($ch, CURLOPT_HEADER, 1);
151 155
 
152
-		if($follow_redirect)        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
156
+		if($follow_redirect) {
157
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
158
+		}
153 159
 
154
-		if(!empty($cookie_string))  curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
155
-		if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
160
+		if(!empty($cookie_string)) {
161
+			curl_setopt($ch, CURLOPT_COOKIE, $cookie_string);
162
+		}
163
+		if(!empty($cookiejar_path)) {
164
+			curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path);
165
+		}
156 166
 
157 167
 		//Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff.
158 168
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2824.0 Safari/537.36');
@@ -362,8 +372,12 @@  discard block
 block discarded – undo
362 372
 		$status = FALSE;
363 373
 
364 374
 		//Make sure we have a volume element
365
-		if(count($oldChapterSegments) === 1) array_unshift($oldChapterSegments, 'v0');
366
-		if(count($newChapterSegments) === 1) array_unshift($newChapterSegments, 'v0');
375
+		if(count($oldChapterSegments) === 1) {
376
+			array_unshift($oldChapterSegments, 'v0');
377
+		}
378
+		if(count($newChapterSegments) === 1) {
379
+			array_unshift($newChapterSegments, 'v0');
380
+		}
367 381
 
368 382
 		$oldCount = count($oldChapterSegments);
369 383
 		$newCount = count($newChapterSegments);
@@ -376,8 +390,12 @@  discard block
 block discarded – undo
376 390
 				$newVolume = substr(array_shift($newChapterSegments), 1);
377 391
 
378 392
 				//Forcing volume to 0 as TBD might not be the latest (although it can be, but that is covered by other checks)
379
-				if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $oldVolume = 0;
380
-				if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) $newVolume = 0;
393
+				if(in_array($oldVolume, ['TBD', 'TBA', 'NA', 'LMT'])) {
394
+					$oldVolume = 0;
395
+				}
396
+				if(in_array($newVolume, ['TBD', 'TBA', 'NA', 'LMT'])) {
397
+					$newVolume = 0;
398
+				}
381 399
 
382 400
 				$oldVolume = floatval($oldVolume);
383 401
 				$newVolume = floatval($newVolume);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
1
+<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed');
2 2
 
3 3
 /**
4 4
  * Class Tracker_Sites_Model
Please login to merge, or discard this patch.