Tracker_Issue_Model   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 16.66%

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
ccs 3
cts 18
cp 0.1666
wmc 7
lcom 1
cbo 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B report() 0 22 6
1
<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class Tracker_Issue_Model extends Tracker_Base_Model {
4 96
	public function __construct() {
5 96
		parent::__construct();
6 96
	}
7
8
9
	public function report(string $text, $userID = NULL, $url = NULL) : bool {
10
		$this->load->library('email');
11
12
		//This is pretty barebones issue reporting, and honestly not a great way to do it, but it works for now (until the Github is public).
13
		$body = "".
14
		        (!is_null($url) && !empty($url) ? "URL: ".htmlspecialchars(substr($url, 0, 255))."<br>\n" : "").
15
		        "Submitted by: ".$this->input->ip_address().(!is_null($userID) ? "| {$userID}" : "")."<br>\n".
16
		        "<br>Bug report: ".htmlspecialchars(substr($text, 0, 1000));
17
18
		$success = TRUE;
19
		$this->email->from('[email protected]', $this->config->item('site_title', 'ion_auth'));
20
		if($this->User->id) {
21
			$this->email->reply_to($this->User->email);
22
		}
23
		$this->email->to('[email protected]');
24
		$this->email->subject($this->config->item('site_title', 'ion_auth')." - Issue Report");
25
		$this->email->message($body);
26
		if(!$this->email->send()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->email->send() of type null|boolean is loosely compared to false; this is ambiguous if the boolean can be false. You might want to explicitly use !== null instead.

If an expression can have both false, and null as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.

$a = canBeFalseAndNull();

// Instead of
if ( ! $a) { }

// Better use one of the explicit versions:
if ($a !== null) { }
if ($a !== false) { }
if ($a !== null && $a !== false) { }
Loading history...
27
			$success = FALSE;
28
		}
29
		return $success;
30
	}
31
32
}
33