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.

ForceRedirect   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 73.17 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_location() 4 4 1
A __construct() 6 6 1
A format_message() 0 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
    /**
26
     * @var string
27
     */
28
	private $location;
29
30
    /**
31
     * @return string
32
     */
33
	protected function get_location()
34
	{
35
		return $this->location;
36
	}
37
38
    /**
39
     * @param string $location
40
     * @param int $code
41
     * @param \Exception|null $previous
42
     */
43
	public function __construct($location, $code = Status::FOUND, \Exception $previous = null)
44
	{
45
		$this->location = $location;
46
47
		parent::__construct($this->format_message($location), $code, $previous);
48
	}
49
50
	/**
51
	 * Formats exception message.
52
	 *
53
	 * @param string $location
54
	 *
55
	 * @return string
56
	 */
57
	protected function format_message($location)
58
	{
59
		return \ICanBoogie\format("Location: %location", [ 'location' => $location ]);
60
	}
61
}
62