TitleHistory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 2
1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class TitleHistory extends Auth_Controller {
4
	public function __construct() {
5
		parent::__construct();
6
	}
7
8
	/**
9
	 * @param int $titleID
10
	 * @param int $page
11
	 */
12
	public function index(int $titleID, int $page = 1) : void {
13
		$this->header_data['title'] = "Title History";
14
		$this->header_data['page']  = "history";
15
16
		//CHECK: Should we only allow people to see history for series they are tracking?
17
		$historyData = $this->History->getTitleHistory((int) $titleID, $page);
18
19
		if(!empty($historyData['title'])) {
20
			$this->body_data['title']       = $historyData['title'];
21
			$this->body_data['historyData'] = $historyData['rows'];
22
			$this->body_data['currentPage'] = $page;
23
			$this->body_data['totalPages']  = $historyData['totalPages'];
24
			$this->body_data['titleID']     = (int) $titleID;
25
26
			if($page > $this->body_data['totalPages'] && $page > 1) redirect("/history/{$titleID}/1");
27
28
			$this->_render_page("TitleHistory");
29
30
		} else {
31
			show_404();
32
		}
33
	}
34
}
35