GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 58ff8d...1de4e3 )
by Olivier
01:28
created

ForceRedirect   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 0
cbo 1
dl 30
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_location() 4 4 1
A __construct() 6 6 1
A format_message() 4 4 1

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
2
3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ICanBoogie\HTTP;
13
14
use ICanBoogie\Accessor\AccessorTrait;
15
16
/**
17
 * Exception thrown to force the redirect of the response.
18
 *
19
 * @property-read string $location The location of the redirect.
20
 */
21 View Code Duplication
class ForceRedirect extends \Exception implements Exception
22
{
23
	use AccessorTrait;
24
25
	private $location;
26
27
	protected function get_location()
28
	{
29
		return $this->location;
30
	}
31
32
	public function __construct($location, $code = Status::FOUND, \Exception $previous = null)
33
	{
34
		$this->location = $location;
35
36
		parent::__construct($this->format_message($location), $code, $previous);
37
	}
38
39
	/**
40
	 * Formats exception message.
41
	 *
42
	 * @param string $location
43
	 *
44
	 * @return string
45
	 */
46
	protected function format_message($location)
47
	{
48
		return \ICanBoogie\format("Location: %location", [ 'location' => $location ]);
49
	}
50
}
51