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 ( 611a27...a833ec )
by Olivier
01:50
created

DispatcherProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 60
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A defined() 0 4 1
A define() 0 8 1
A provide() 0 11 2
A clear() 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;
13
14
/**
15
 * Provides a {@link Dispatcher} instance.
16
 */
17
class DispatcherProvider
18
{
19
	/**
20
	 * @var callable {@link Dispatcher} provider
21
	 */
22
	static private $provider;
23
24
	/**
25
	 * Whether a provider if defined.
26
	 *
27
	 * @return bool
28
	 */
29
	static public function defined()
30
	{
31
		return isset(self::$provider);
32
	}
33
34
	/**
35
	 * Defines the {@link Dispatcher} provider.
36
	 *
37
	 * @param callable $provider
38
	 *
39
	 * @return callable|null The previous provider, or `null` if none was defined before.
40
	 */
41
	static public function define(callable $provider)
42
	{
43
		$previous = self::$provider;
44
45
		self::$provider = $provider;
46
47
		return $previous;
48
	}
49
50
	/**
51
	 * Returns a {@link Dispatcher} instance using the provider.
52
	 *
53
	 * @return Dispatcher
54
	 *
55
	 * @throws DispatcherProviderNotDefined if no provider is defined.
56
	 */
57
	static public function provide()
58
	{
59
		$provider = self::$provider;
60
61
		if (!$provider)
62
		{
63
			throw new DispatcherProviderNotDefined;
64
		}
65
66
		return $provider();
67
	}
68
69
	/**
70
	 * Clears the provider.
71
	 */
72
	static public function clear()
73
	{
74
		self::$provider = null;
75
	}
76
}
77