|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ndrx\Profiler; |
|
4
|
|
|
|
|
5
|
|
|
use Ndrx\Profiler\Components\Logs\Simple; |
|
6
|
|
|
use Ndrx\Profiler\Context\NullContext; |
|
7
|
|
|
use Ndrx\Profiler\DataSources\NullDataSource; |
|
8
|
|
|
use Psr\Log\LoggerInterface; |
|
9
|
|
|
use Ndrx\Profiler\Collectors\Contracts\CollectorInterface; |
|
10
|
|
|
use Ndrx\Profiler\Components\Timeline; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class NullProfiler |
|
14
|
|
|
* |
|
15
|
|
|
* @method void start($key, $label, $data = null, $timetamp = null) Start a timeline event |
|
16
|
|
|
* @method void stop($key, $timestamp = null) Stop a timeline event |
|
17
|
|
|
* @method mixed monitor($label, \Closure $closure) Monitor a function |
|
18
|
|
|
* |
|
19
|
|
|
* @method NullContext emergency($message, array $context = array()) |
|
20
|
|
|
* @method NullContext alert($message, array $context = array()) |
|
21
|
|
|
* @method NullContext critical($message, array $context = array()) |
|
22
|
|
|
* @method NullContext error($message, array $context = array()) |
|
23
|
|
|
* @method NullContext warning($message, array $context = array()) |
|
24
|
|
|
* @method NullContext notice($message, array $context = array()) |
|
25
|
|
|
* @method NullContext info($message, array $context = array()) |
|
26
|
|
|
* @method NullContext debug($message, array $context = array()) |
|
27
|
|
|
* @method NullContext log($level, $message, array $context = array()) |
|
28
|
|
|
* |
|
29
|
|
|
* @package Ndrx\Profiler |
|
30
|
|
|
*/ |
|
31
|
|
|
class NullProfiler implements ProfilerInterface |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* Sets a logger instance on the object |
|
35
|
|
|
* |
|
36
|
|
|
* @param \Psr\Log\LoggerInterface $logger |
|
37
|
|
|
* @return null |
|
38
|
|
|
*/ |
|
39
|
2 |
|
public function setLogger(LoggerInterface $logger) |
|
40
|
|
|
{ |
|
41
|
2 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return string |
|
45
|
|
|
*/ |
|
46
|
2 |
|
public static function detectEnv() |
|
47
|
|
|
{ |
|
48
|
2 |
|
return 'null'; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @author LAHAXE Arnaud |
|
53
|
|
|
*/ |
|
54
|
2 |
|
public static function destroy() |
|
55
|
|
|
{ |
|
56
|
2 |
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Add a data collector to the profiler |
|
60
|
|
|
* @param \Ndrx\Profiler\Collectors\Contracts\CollectorInterface $collector |
|
61
|
|
|
* @throws \RuntimeException |
|
62
|
|
|
*/ |
|
63
|
2 |
|
public function registerCollector(CollectorInterface $collector) |
|
64
|
|
|
{ |
|
65
|
2 |
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Register multiple collector to the profiler |
|
69
|
|
|
* @param array $collectors |
|
70
|
|
|
* @throws \RuntimeException |
|
71
|
|
|
*/ |
|
72
|
2 |
|
public function registerCollectors(array $collectors) |
|
73
|
|
|
{ |
|
74
|
2 |
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Build and register collector class |
|
78
|
|
|
* @param $className |
|
79
|
|
|
* @throws \RuntimeException |
|
80
|
|
|
*/ |
|
81
|
2 |
|
public function registerCollectorClass($className) |
|
82
|
|
|
{ |
|
83
|
2 |
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Build and register collector classes |
|
87
|
|
|
* @param array $collectors |
|
88
|
|
|
* @throws \RuntimeException |
|
89
|
|
|
*/ |
|
90
|
2 |
|
public function registerCollectorClasses(array $collectors) |
|
91
|
|
|
{ |
|
92
|
2 |
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Run start collector at the profiler creation |
|
96
|
|
|
*/ |
|
97
|
8 |
|
public function initiate() |
|
98
|
|
|
{ |
|
99
|
8 |
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Run final collectors, just before the profiler was destroy |
|
103
|
|
|
*/ |
|
104
|
8 |
|
public function terminate() |
|
105
|
|
|
{ |
|
106
|
8 |
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @param $name |
|
110
|
|
|
* @return mixed |
|
111
|
|
|
*/ |
|
112
|
2 |
|
public function runGroup($name) |
|
113
|
|
|
{ |
|
114
|
2 |
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @param \Ndrx\Profiler\DataSources\Contracts\DataSourceInterface $datasource |
|
118
|
|
|
*/ |
|
119
|
2 |
|
public function setDataSource($datasource) |
|
120
|
|
|
{ |
|
121
|
2 |
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return \Ndrx\Profiler\DataSources\Contracts\DataSourceInterface |
|
125
|
|
|
*/ |
|
126
|
2 |
|
public function getDatasource() |
|
127
|
|
|
{ |
|
128
|
2 |
|
return new NullDataSource(); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @param $id |
|
133
|
|
|
* @return mixed |
|
134
|
|
|
*/ |
|
135
|
2 |
|
public function getProfile($id) |
|
136
|
|
|
{ |
|
137
|
2 |
|
return new \stdClass(); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @return \Ndrx\Profiler\Context\Contracts\ContextInterface |
|
142
|
|
|
*/ |
|
143
|
2 |
|
public function getContext() |
|
144
|
|
|
{ |
|
145
|
2 |
|
return new NullContext(); |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* @param $name |
|
150
|
|
|
* @param $arguments |
|
151
|
|
|
* @return mixed |
|
152
|
|
|
* @throws \BadMethodCallException |
|
153
|
|
|
*/ |
|
154
|
2 |
|
public function __call($name, $arguments) |
|
155
|
|
|
{ |
|
156
|
2 |
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @param Timeline $timeline |
|
160
|
|
|
*/ |
|
161
|
2 |
|
public function setTimeline($timeline) |
|
162
|
|
|
{ |
|
163
|
2 |
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* @return LoggerInterface |
|
167
|
|
|
*/ |
|
168
|
2 |
|
public function getLogger() |
|
169
|
|
|
{ |
|
170
|
2 |
|
return new Simple(); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @return array |
|
175
|
|
|
*/ |
|
176
|
|
|
public function getCollectors() |
|
177
|
|
|
{ |
|
178
|
|
|
return []; |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
|