Completed
Push — master ( 7dd2dd...7e98b2 )
by Adam
03:24 queued 01:04
created

Configuration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 40
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRedirectUrl() 0 8 2
1
<?php
2
/**
3
 * Configuration.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:Permissions!
9
 * @subpackage     common
10
 * @since          2.0.0
11
 *
12
 * @date           17.02.15
13
 */
14
15
namespace IPub\Permissions;
16
17
use Nette;
18
use Nette\Application;
19
20
/**
21
 * Permissions's extension configuration storage. Store basic extension settings
22
 *
23
 * @package        iPublikuj:Permissions!
24
 * @subpackage     common
25
 *
26
 * @author         Adam Kadlec <[email protected]>
27
 */
28 1
class Configuration extends Nette\Object
29
{
30
	/**
31
	 * @var string|NULL
32
	 */
33
	private $redirectUrl;
34
35
	/**
36
	 * @var Application\LinkGenerator
37
	 */
38
	private $linkGenerator;
39
40
	/**
41
	 * @param string|NULL $redirectUrl
42
	 * @param Application\LinkGenerator $linkGenerator
43
	 */
44
	public function __construct(string $redirectUrl = NULL, Application\LinkGenerator $linkGenerator)
45
	{
46 1
		$this->redirectUrl = $redirectUrl;
47 1
		$this->linkGenerator = $linkGenerator;
48 1
	}
49
50
	/**
51
	 * Build the URL for redirection if is set
52
	 *
53
	 * @param array $params
54
	 *
55
	 * @return string|NULL
56
	 *
57
	 * @throws Application\UI\InvalidLinkException
58
	 */
59
	public function getRedirectUrl(array $params = [])
60
	{
61 1
		if ($this->redirectUrl) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->redirectUrl of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
62
			return $this->linkGenerator->link($this->redirectUrl, $params);
63
		}
64
65 1
		return NULL;
66
	}
67
}
68