1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* User: LAHAXE Arnaud |
4
|
|
|
* Date: 05/11/2015 |
5
|
|
|
* Time: 12:40 |
6
|
|
|
* FileName : User.php |
7
|
|
|
* Project : profiler |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Ndrx\Profiler\Collectors\Data; |
11
|
|
|
|
12
|
|
|
use Ndrx\Profiler\Collectors\Collector; |
13
|
|
|
use Ndrx\Profiler\Collectors\Contracts\StartCollectorInterface; |
14
|
|
|
use Ndrx\Profiler\Renderer\BarRenderableInterface; |
15
|
|
|
use Ndrx\Profiler\Renderer\RendererInterface; |
16
|
|
|
|
17
|
|
|
abstract class User extends Collector implements StartCollectorInterface, BarRenderableInterface |
18
|
|
|
{ |
19
|
|
|
protected $user; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Fetch data |
23
|
|
|
* |
24
|
|
|
* @return mixed |
25
|
|
|
*/ |
26
|
6 |
|
public function resolve() |
27
|
|
|
{ |
28
|
6 |
|
$this->data = [ |
29
|
6 |
|
'id' => $this->getId(), |
30
|
6 |
|
'identifier' => $this->getIdentifier(), |
31
|
6 |
|
'detail' => $this->getDetails() |
32
|
6 |
|
]; |
33
|
6 |
|
} |
34
|
|
|
|
35
|
6 |
|
public function getDataFields() |
36
|
|
|
{ |
37
|
|
|
return [ |
38
|
6 |
|
'id', 'identifier', 'detail' |
39
|
6 |
|
]; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The path in the final json |
44
|
|
|
* |
45
|
|
|
* @example |
46
|
|
|
* path /aa/bb |
47
|
|
|
* will be transformed to |
48
|
|
|
* { |
49
|
|
|
* aa : { |
50
|
|
|
* bb: <VALUE OF RESOLVE> |
51
|
|
|
* } |
52
|
|
|
* } |
53
|
|
|
* @return string |
54
|
|
|
*/ |
55
|
2 |
|
public function getPath() |
56
|
|
|
{ |
57
|
2 |
|
return 'user'; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return mixed |
62
|
|
|
*/ |
63
|
2 |
|
public function getUser() |
64
|
|
|
{ |
65
|
2 |
|
return $this->user; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param mixed $user |
70
|
|
|
* |
71
|
|
|
* @return self |
72
|
|
|
*/ |
73
|
6 |
|
public function setUser($user) |
74
|
|
|
{ |
75
|
6 |
|
$this->user = $user; |
76
|
|
|
|
77
|
6 |
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return RendererInterface |
82
|
|
|
* |
83
|
|
|
* @throws \RuntimeException |
84
|
|
|
*/ |
85
|
|
|
public function getRenderer() |
86
|
|
|
{ |
87
|
|
|
return new \Ndrx\Profiler\Renderer\Html\Data\User(); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Return the user user identifier email/username or whatever |
92
|
|
|
* |
93
|
|
|
* @return string |
94
|
|
|
*/ |
95
|
|
|
abstract public function getIdentifier(); |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Return the user id or uuid |
99
|
|
|
* |
100
|
|
|
* @return string|int |
101
|
|
|
*/ |
102
|
|
|
abstract public function getId(); |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* User details for examples roles, timestamps... |
106
|
|
|
* |
107
|
|
|
* @return array |
108
|
|
|
*/ |
109
|
|
|
abstract public function getDetails(); |
110
|
|
|
} |
111
|
|
|
|