Completed
Push — master ( b201fa...f0a23c )
by Angus
06:43
created
application/models/Tracker/Tracker_List_Model.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  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
 class Tracker_List_Model extends Tracker_Base_Model {
4 4
 	public function __construct() {
5 5
 		parent::__construct();
6 6
 	}
7 7
 
8
-	public function get(?int $userID = NULL) {
8
+	public function get(? int $userID = NULL) {
9 9
 		$userID = (is_null($userID) ? (int) $this->User->id : $userID);
10 10
 
11 11
 		$query = $this->db
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			];
30 30
 		}
31 31
 		if($query->num_rows() > 0) {
32
-			foreach ($query->result() as $row) {
32
+			foreach($query->result() as $row) {
33 33
 				$is_unread = intval(($row->latest_chapter == $row->ignore_chapter) || ($row->latest_chapter == $row->current_chapter) ? '1' : '0');
34 34
 				$arr['series'][$row->category]['unread_count'] = (($arr['series'][$row->category]['unread_count'] ?? 0) + !$is_unread);
35 35
 				$data = [
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 			$sortOrder = $this->User_Options->get('list_sort_order', $userID);
83 83
 			switch($this->User_Options->get('list_sort_type', $userID)) {
84 84
 				case 'unread':
85
-					foreach (array_keys($arr['series']) as $category) {
86
-						usort($arr['series'][$category]['manga'], function ($a, $b) use($sortOrder) {
85
+					foreach(array_keys($arr['series']) as $category) {
86
+						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
87 87
 							$a_text = strtolower("{$a['new_chapter_exists']} - {$a['title_data']['title']}");
88 88
 							$b_text = strtolower("{$b['new_chapter_exists']} - {$b['title_data']['title']}");
89 89
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 					break;
98 98
 
99 99
 				case 'unread_latest':
100
-					foreach (array_keys($arr['series']) as $category) {
101
-						usort($arr['series'][$category]['manga'], function ($a, $b) use($sortOrder) {
100
+					foreach(array_keys($arr['series']) as $category) {
101
+						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
102 102
 							$a_text = $a['new_chapter_exists'];
103 103
 							$b_text = $b['new_chapter_exists'];
104 104
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 					break;
120 120
 
121 121
 				case 'alphabetical':
122
-					foreach (array_keys($arr['series']) as $category) {
122
+					foreach(array_keys($arr['series']) as $category) {
123 123
 						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
124 124
 							$a_text = strtolower("{$a['title_data']['title']}");
125 125
 							$b_text = strtolower("{$b['title_data']['title']}");
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 					break;
135 135
 
136 136
 				case 'my_status':
137
-					foreach (array_keys($arr['series']) as $category) {
137
+					foreach(array_keys($arr['series']) as $category) {
138 138
 						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
139 139
 							$a_text = strtolower("{$a['generated_current_data']['number']}");
140 140
 							$b_text = strtolower("{$b['generated_current_data']['number']}");
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 					break;
150 150
 
151 151
 				case 'latest':
152
-					foreach (array_keys($arr['series']) as $category) {
152
+					foreach(array_keys($arr['series']) as $category) {
153 153
 						usort($arr['series'][$category]['manga'], function($a, $b) use($sortOrder) {
154 154
 							$a_text = new DateTime("{$a['title_data']['last_updated']}");
155 155
 							$b_text = new DateTime("{$b['title_data']['last_updated']}");
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 		return $status;
282 282
 	}
283 283
 
284
-	public function getMalID(int $userID, int $titleID) : ?array{
284
+	public function getMalID(int $userID, int $titleID) : ? array{
285 285
 		$malIDArr = NULL;
286 286
 
287 287
 		//NEW METHOD
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 			                  ->get('tracker_chapters');
320 320
 
321 321
 			if($queryC2->num_rows() > 0 && ($tag_string = $queryC2->row()->tags) && !is_null($tag_string)) {
322
-				$arr   = preg_grep('/^mal:([0-9]+|none)$/', explode(',', $tag_string));
322
+				$arr = preg_grep('/^mal:([0-9]+|none)$/', explode(',', $tag_string));
323 323
 				if(!empty($arr)) {
324 324
 					$malIDArr = [
325 325
 						'id'   => explode(':', $arr[0])[1],
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
 		return $malIDArr;
333 333
 	}
334
-	public function setMalID(int $userID, int $chapterID, ?int $malID) : bool {
334
+	public function setMalID(int $userID, int $chapterID, ? int $malID) : bool {
335 335
 		//TODO: Handle NULL?
336 336
 		$success = (bool) $this->db->set(['mal_id' => $malID, 'active' => 'Y', 'last_updated' => NULL])
337 337
 		                           ->where('user_id', $userID)
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,8 +72,12 @@  discard block
 block discarded – undo
72 72
 
73 73
 				$arr['series'][$row->category]['manga'][] = $data;
74 74
 
75
-				if(!$arr['has_inactive']) $arr['has_inactive'] = !$data['title_data']['active'];
76
-				if($arr['has_inactive'])  $arr['inactive_titles'][$data['full_title_url']] = $data['title_data']['title'];
75
+				if(!$arr['has_inactive']) {
76
+					$arr['has_inactive'] = !$data['title_data']['active'];
77
+				}
78
+				if($arr['has_inactive']) {
79
+					$arr['inactive_titles'][$data['full_title_url']] = $data['title_data']['title'];
80
+				}
77 81
 			}
78 82
 
79 83
 			//FIXME: This is not good for speed, but we're kind of required to do this for UX purposes.
@@ -107,11 +111,15 @@  discard block
 block discarded – undo
107 111
 
108 112
 							if($sortOrder == 'asc') {
109 113
 								$unreadSort = ($a_text <=> $b_text);
110
-								if($unreadSort) return $unreadSort;
114
+								if($unreadSort) {
115
+									return $unreadSort;
116
+								}
111 117
 								return $a_text2 <=> $b_text2;
112 118
 							} else {
113 119
 								$unreadSort = ($a_text <=> $b_text);
114
-								if($unreadSort) return $unreadSort;
120
+								if($unreadSort) {
121
+									return $unreadSort;
122
+								}
115 123
 								return $b_text2 <=> $a_text2;
116 124
 							}
117 125
 						});
Please login to merge, or discard this patch.