Data::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 3
1
<?php
2
3
namespace Psecio\Invoke;
4
5
class Data
6
{
7
	/**
8
	 * Current user instance
9
	 * @var \Psecio\Invoke\UserInterface
10
	 */
11
	private $user;
12
13
	/**
14
	 * Current resource being accessed
15
	 * @var \Psecio\Invoke\Resource
16
	 */
17
	private $resource;
18
19
	/**
20
	 * Current route match for the request
21
	 * @var \Psecio\Invoke\RouteContainer
22
	 */
23
	private $route;
24
25
	/**
26
	 * Current enforcer object
27
	 * @var array
28
	 */
29
	private $enforcer;
30
31
	public function __construct(UserInterface $user, $resource, $route = null)
32
	{
33
		$this->user = $user;
34
		$this->resource = $resource;
35
36
		if ($route !== null) {
37
			$this->route = $route;
38
		}
39
	}
40
41
	public function __get($name)
42
	{
43
		$method = 'get'.ucwords(strtolower($name));
44
		if (method_exists($this, $method)) {
45
			return $this->$method();
46
		}
47
		return null;
48
	}
49
50
	/**
51
	 * Get the current user instance
52
	 *
53
	 * @return \Psecio\Invoke\InvokeUser instance
54
	 */
55
	public function getUser()
56
	{
57
		return $this->user;
58
	}
59
60
	/**
61
	 * Get the current route information
62
	 *
63
	 * @return \Psecio\Invoke\RouteContainer instance
64
	 */
65
	public function getRoute()
66
	{
67
		return $this->route;
68
	}
69
70
	/**
71
	 * Get the current resource instance
72
	 *
73
	 * @return \Psecio\Invoke\Resource instance
74
	 */
75
	public function getResource()
76
	{
77
		return $this->resource;
78
	}
79
80
	/**
81
	 * Set the current route instance
82
	 *
83
	 * @param \Psecio\Invoke\RouteContaine $route Instance
84
	 */
85
	public function setRoute(RouteContainer $route)
86
	{
87
		$this->route = $route;
88
	}
89
90
	/**
91
	 * Set the current enforcer object
92
	 *
93
	 * @param \Psecio\Invoke\Enforcer $enforcer Enforcer object
94
	 */
95
	public function setEnforcer(\Psecio\Invoke\Enforcer &$enforcer)
96
	{
97
		$this->enforcer = $enforcer;
0 ignored issues
show
Documentation Bug introduced by
It seems like $enforcer of type object<Psecio\Invoke\Enforcer> is incompatible with the declared type array of property $enforcer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
98
	}
99
100
	/**
101
	 * Get the current enforcer object
102
	 *
103
	 * @return object Enforder object
104
	 */
105
	public function getEnforcer()
106
	{
107
		return $this->enforcer;
108
	}
109
}