PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / vendor / prefixed / symfony / http-kernel / Profiler / Profile.php
matomo / app / vendor / prefixed / symfony / http-kernel / Profiler Last commit date
FileProfilerStorage.php 1 year ago Profile.php 2 years ago Profiler.php 1 year ago ProfilerStorageInterface.php 2 years ago
Profile.php
237 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Matomo\Dependencies\Symfony\Component\HttpKernel\Profiler;
12
13 use Matomo\Dependencies\Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
14 /**
15 * Profile.
16 *
17 * @author Fabien Potencier <fabien@symfony.com>
18 */
19 class Profile
20 {
21 private $token;
22 /**
23 * @var DataCollectorInterface[]
24 */
25 private $collectors = [];
26 private $ip;
27 private $method;
28 private $url;
29 private $time;
30 private $statusCode;
31 /**
32 * @var Profile
33 */
34 private $parent;
35 /**
36 * @var Profile[]
37 */
38 private $children = [];
39 public function __construct(string $token)
40 {
41 $this->token = $token;
42 }
43 public function setToken(string $token)
44 {
45 $this->token = $token;
46 }
47 /**
48 * Gets the token.
49 *
50 * @return string
51 */
52 public function getToken()
53 {
54 return $this->token;
55 }
56 /**
57 * Sets the parent token.
58 */
59 public function setParent(self $parent)
60 {
61 $this->parent = $parent;
62 }
63 /**
64 * Returns the parent profile.
65 *
66 * @return self|null
67 */
68 public function getParent()
69 {
70 return $this->parent;
71 }
72 /**
73 * Returns the parent token.
74 *
75 * @return string|null
76 */
77 public function getParentToken()
78 {
79 return $this->parent ? $this->parent->getToken() : null;
80 }
81 /**
82 * Returns the IP.
83 *
84 * @return string|null
85 */
86 public function getIp()
87 {
88 return $this->ip;
89 }
90 public function setIp(?string $ip)
91 {
92 $this->ip = $ip;
93 }
94 /**
95 * Returns the request method.
96 *
97 * @return string|null
98 */
99 public function getMethod()
100 {
101 return $this->method;
102 }
103 public function setMethod(string $method)
104 {
105 $this->method = $method;
106 }
107 /**
108 * Returns the URL.
109 *
110 * @return string|null
111 */
112 public function getUrl()
113 {
114 return $this->url;
115 }
116 public function setUrl(?string $url)
117 {
118 $this->url = $url;
119 }
120 /**
121 * @return int
122 */
123 public function getTime()
124 {
125 return $this->time ?? 0;
126 }
127 public function setTime(int $time)
128 {
129 $this->time = $time;
130 }
131 public function setStatusCode(int $statusCode)
132 {
133 $this->statusCode = $statusCode;
134 }
135 /**
136 * @return int|null
137 */
138 public function getStatusCode()
139 {
140 return $this->statusCode;
141 }
142 /**
143 * Finds children profilers.
144 *
145 * @return self[]
146 */
147 public function getChildren()
148 {
149 return $this->children;
150 }
151 /**
152 * Sets children profiler.
153 *
154 * @param Profile[] $children
155 */
156 public function setChildren(array $children)
157 {
158 $this->children = [];
159 foreach ($children as $child) {
160 $this->addChild($child);
161 }
162 }
163 /**
164 * Adds the child token.
165 */
166 public function addChild(self $child)
167 {
168 $this->children[] = $child;
169 $child->setParent($this);
170 }
171 public function getChildByToken(string $token) : ?self
172 {
173 foreach ($this->children as $child) {
174 if ($token === $child->getToken()) {
175 return $child;
176 }
177 }
178 return null;
179 }
180 /**
181 * Gets a Collector by name.
182 *
183 * @return DataCollectorInterface
184 *
185 * @throws \InvalidArgumentException if the collector does not exist
186 */
187 public function getCollector(string $name)
188 {
189 if (!isset($this->collectors[$name])) {
190 throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
191 }
192 return $this->collectors[$name];
193 }
194 /**
195 * Gets the Collectors associated with this profile.
196 *
197 * @return DataCollectorInterface[]
198 */
199 public function getCollectors()
200 {
201 return $this->collectors;
202 }
203 /**
204 * Sets the Collectors associated with this profile.
205 *
206 * @param DataCollectorInterface[] $collectors
207 */
208 public function setCollectors(array $collectors)
209 {
210 $this->collectors = [];
211 foreach ($collectors as $collector) {
212 $this->addCollector($collector);
213 }
214 }
215 /**
216 * Adds a Collector.
217 */
218 public function addCollector(DataCollectorInterface $collector)
219 {
220 $this->collectors[$collector->getName()] = $collector;
221 }
222 /**
223 * @return bool
224 */
225 public function hasCollector(string $name)
226 {
227 return isset($this->collectors[$name]);
228 }
229 /**
230 * @return array
231 */
232 public function __sleep()
233 {
234 return ['token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode'];
235 }
236 }
237