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
Pull Request — master (#9)
by Lukáš
02:17
created

RedirectConfig::redirectToApproveDestination()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Lookyman\NetteOAuth2Server;
5
6
use Nette\Application\UI\Component;
7
use Nette\InvalidStateException;
8
use Nette\SmartObject;
9
10
/**
11
 * @method void onBeforeApproveRedirect(RedirectConfig $redirectConfig)
12
 * @method void onBeforeLoginRedirect(RedirectConfig $redirectConfig)
13
 */
14
class RedirectConfig
15
{
16
	use SmartObject;
17
18
	/**
19
	 * @var callable[]
20
	 */
21
	public $onBeforeApproveRedirect = [];
22
23
	/**
24
	 * @var callable[]
25
	 */
26
	public $onBeforeLoginRedirect = [];
27
28
	/**
29
	 * @var array
30
	 */
31
	private $approveDestination;
32
33
	/**
34
	 * @var array
35
	 */
36
	private $loginDestination;
37
38
	/**
39
	 * @param string|array|null $approveDestination
40
	 * @param string|array|null $loginDestination
41
	 */
42
	public function __construct($approveDestination, $loginDestination)
43
	{
44
		$this->setApproveDestination($approveDestination);
45
		$this->setLoginDestination($loginDestination);
46
	}
47
48
	/**
49
	 * @param string|array|null $approveDestination
50
	 */
51
	public function setApproveDestination($approveDestination)
52
	{
53
		$this->approveDestination = (array) $approveDestination;
54
	}
55
56
	/**
57
	 * @param Component $component
58
	 * @throws InvalidStateException
59
	 */
60
	public function redirectToApproveDestination(Component $component)
61
	{
62
		if (empty($this->approveDestination)) {
63
			throw new InvalidStateException('Approve destination not set');
64
		}
65
		$this->onBeforeApproveRedirect($this);
66
		$component->redirect(...$this->approveDestination);
67
	}
68
69
	/**
70
	 * @param string|array|null $loginDestination
71
	 */
72
	public function setLoginDestination($loginDestination)
73
	{
74
		$this->loginDestination = (array) $loginDestination;
75
	}
76
77
	/**
78
	 * @param Component $component
79
	 * @throws InvalidStateException
80
	 */
81
	public function redirectToLoginDestination(Component $component)
82
	{
83
		if (empty($this->loginDestination)) {
84
			throw new InvalidStateException('Login destination not set');
85
		}
86
		$this->onBeforeLoginRedirect($this);
87
		$component->redirect(...$this->loginDestination);
88
	}
89
}
90