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 (#10)
by Lukáš
07:03
created

RedirectConfig   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 46
c 0
b 0
f 0
wmc 5
lcom 2
cbo 1
rs 10

1 Method

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