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 ( d0ae18...d55d37 )
by Olivier
04:32 queued 59s
created

Context::offsetExists()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 13
rs 9.4285
cc 2
eloc 6
nc 1
nop 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
	protected function get_request()
40
	{
41
		return $this->request;
42
	}
43
44
	/**
45
	 * The dispatcher currently dispatching the request.
46
	 *
47
	 * @var Dispatcher|null
48
	 */
49
	private $dispatcher;
50
51
	/**
52
	 * Sets the dispatcher currently dispatching the request.
53
	 *
54
	 * @param Dispatcher|null $dispatcher
55
	 *
56
	 * @throws \InvalidArgumentException if the value is not null and does not implements {@link Dispatcher}.
57
	 */
58
	protected function set_dispatcher($dispatcher)
59
	{
60
		if ($dispatcher !== null && !($dispatcher instanceof Dispatcher))
61
		{
62
			throw new \InvalidArgumentException('$dispatcher must be an instance of ICanBoogie\HTTP\DispatcherInterface. Given: ' . get_class($dispatcher) . '.');
63
		}
64
65
		$this->dispatcher = $dispatcher;
66
	}
67
68
	protected function get_dispatcher()
69
	{
70
		return $this->dispatcher;
71
	}
72
73
	/**
74
	 * @param Request $request The request the context belongs to.
75
	 */
76
	public function __construct(Request $request)
77
	{
78
		$this->request = $request;
79
	}
80
81
	/**
82
	 * @inheritdoc
83
	 */
84
	public function offsetExists($property)
85
	{
86
		try
87
		{
88
			$this->$property;
89
90
			return true;
91
		}
92
		catch (PropertyNotDefined $e)
93
		{
94
			return false;
95
		}
96
	}
97
98
	/**
99
	 * @inheritdoc
100
	 */
101
	public function offsetGet($property)
102
	{
103
		return $this->$property;
104
	}
105
106
	/**
107
	 * @inheritdoc
108
	 */
109
	public function offsetSet($property, $value)
110
	{
111
		$this->$property = $value;
112
	}
113
114
	/**
115
	 * @inheritdoc
116
	 */
117
	public function offsetUnset($property)
118
	{
119
		unset($this->$property);
120
	}
121
}
122