Completed
Push — master ( 4a1c4b...dec28d )
by Angus
03:08
created

Logout   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 36.67 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
dl 11
loc 30
ccs 15
cts 16
cp 0.9375
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A index() 0 14 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class Logout extends User_Controller {
4
	//we shouldn't care if the user is logged in or not, since ion_auth will take care of things
5
6 1 View Code Duplication
	public function __construct() {
7 1
		parent::__construct();
8
9 1
		$this->load->helper('cookie');
10
11 1
		$this->load->library('form_validation');
12 1
		$this->form_validation->set_error_delimiters(
13 1
			$this->config->item('error_start_delimiter', 'ion_auth'),
14 1
			$this->config->item('error_end_delimiter', 'ion_auth')
15
		);
16 1
	}
17
18 1
	public function index() : void {
19 1
		$this->header_data['title'] = 'Logout';
20 1
		$this->header_data['page']  = 'logout';
21
22 1
		if($this->ion_auth->logged_in()) {
23
			//This is called again due to logout not always logging out properly. - https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/1191#issuecomment-378934024
24
			$this->ion_auth->logout() && $this->ion_auth->logout();
25
		}
26 1
		$this->session->set_flashdata('notices', 'Logout Successful');
27
28 1
		delete_cookie('remember_time');
29
30 1
		redirect('/', 'refresh'); //TODO: Should we have a custom logout page?
31
	} //@codeCoverageIgnore
32
}
33