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.

Context   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 100
rs 10
c 0
b 0
f 0
wmc 11
lcom 1
cbo 1

8 Methods

Rating   Name   Duplication   Size   Complexity  
A get_request() 0 4 1
A set_dispatcher() 0 9 3
A get_dispatcher() 0 4 1
A __construct() 0 4 1
A offsetExists() 0 13 2
A offsetGet() 0 4 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
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\Request;
13
14
use ICanBoogie\HTTP\Dispatcher;
15
use ICanBoogie\HTTP\Request;
16
use ICanBoogie\PropertyNotDefined;
17
use ICanBoogie\PrototypeTrait;
18
19
/**
20
 * The context of a request.
21
 *
22
 * This is a general purpose container used to store the objects and variables related to a
23
 * request.
24
 *
25
 * @property-read Request $request The request associated with the context.
26
 * @property Dispatcher $dispatcher The dispatcher currently dispatching the request.
27
 */
28
class Context implements \ArrayAccess
29
{
30
	use PrototypeTrait;
31
32
	/**
33
	 * The request the context belongs to.
34
	 *
35
	 * @var Request
36
	 */
37
	private $request;
38
39
    /**
40
     * @return Request
41
     */
42
	protected function get_request()
43
	{
44
		return $this->request;
45
	}
46
47
	/**
48
	 * The dispatcher currently dispatching the request.
49
	 *
50
	 * @var Dispatcher|null
51
	 */
52
	private $dispatcher;
53
54
	/**
55
	 * Sets the dispatcher currently dispatching the request.
56
	 *
57
	 * @param Dispatcher|null $dispatcher
58
	 *
59
	 * @throws \InvalidArgumentException if the value is not null and does not implements {@link Dispatcher}.
60
	 */
61
	protected function set_dispatcher($dispatcher)
62
	{
63
		if ($dispatcher !== null && !$dispatcher instanceof Dispatcher)
64
		{
65
			throw new \InvalidArgumentException('$dispatcher must be an instance of ICanBoogie\HTTP\DispatcherInterface. Given: ' . get_class($dispatcher) . '.');
66
		}
67
68
		$this->dispatcher = $dispatcher;
69
	}
70
71
    /**
72
     * @return Dispatcher|null
73
     */
74
	protected function get_dispatcher()
75
	{
76
		return $this->dispatcher;
77
	}
78
79
	/**
80
	 * @param Request $request The request the context belongs to.
81
	 */
82
	public function __construct(Request $request)
83
	{
84
		$this->request = $request;
85
	}
86
87
	/**
88
	 * @inheritdoc
89
	 */
90
	public function offsetExists($property)
91
	{
92
		try
93
		{
94
			$this->$property;
95
96
			return true;
97
		}
98
		catch (PropertyNotDefined $e)
99
		{
100
			return false;
101
		}
102
	}
103
104
	/**
105
	 * @inheritdoc
106
	 */
107
	public function offsetGet($property)
108
	{
109
		return $this->$property;
110
	}
111
112
	/**
113
	 * @inheritdoc
114
	 */
115
	public function offsetSet($property, $value)
116
	{
117
		$this->$property = $value;
118
	}
119
120
	/**
121
	 * @inheritdoc
122
	 */
123
	public function offsetUnset($property)
124
	{
125
		unset($this->$property);
126
	}
127
}
128