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 / DataCollector / TimeDataCollector.php
matomo / app / vendor / prefixed / symfony / http-kernel / DataCollector Last commit date
AjaxDataCollector.php 2 years ago ConfigDataCollector.php 1 year ago DataCollector.php 2 years ago DataCollectorInterface.php 2 years ago DumpDataCollector.php 1 year ago EventDataCollector.php 2 years ago ExceptionDataCollector.php 2 years ago LateDataCollectorInterface.php 2 years ago LoggerDataCollector.php 1 year ago MemoryDataCollector.php 1 year ago RequestDataCollector.php 1 year ago RouterDataCollector.php 1 year ago TimeDataCollector.php 1 year ago
TimeDataCollector.php
121 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\DataCollector;
12
13 use Matomo\Dependencies\Symfony\Component\HttpFoundation\Request;
14 use Matomo\Dependencies\Symfony\Component\HttpFoundation\Response;
15 use Matomo\Dependencies\Symfony\Component\HttpKernel\KernelInterface;
16 use Symfony\Component\Stopwatch\Stopwatch;
17 use Symfony\Component\Stopwatch\StopwatchEvent;
18 /**
19 * @author Fabien Potencier <fabien@symfony.com>
20 *
21 * @final
22 */
23 class TimeDataCollector extends DataCollector implements LateDataCollectorInterface
24 {
25 private $kernel;
26 private $stopwatch;
27 public function __construct(?KernelInterface $kernel = null, ?Stopwatch $stopwatch = null)
28 {
29 $this->kernel = $kernel;
30 $this->stopwatch = $stopwatch;
31 $this->data = ['events' => [], 'stopwatch_installed' => \false, 'start_time' => 0];
32 }
33 /**
34 * {@inheritdoc}
35 */
36 public function collect(Request $request, Response $response, ?\Throwable $exception = null)
37 {
38 if (null !== $this->kernel) {
39 $startTime = $this->kernel->getStartTime();
40 } else {
41 $startTime = $request->server->get('REQUEST_TIME_FLOAT');
42 }
43 $this->data = ['token' => $request->attributes->get('_stopwatch_token'), 'start_time' => $startTime * 1000, 'events' => [], 'stopwatch_installed' => class_exists(Stopwatch::class, \false)];
44 }
45 /**
46 * {@inheritdoc}
47 */
48 public function reset()
49 {
50 $this->data = ['events' => [], 'stopwatch_installed' => \false, 'start_time' => 0];
51 if (null !== $this->stopwatch) {
52 $this->stopwatch->reset();
53 }
54 }
55 /**
56 * {@inheritdoc}
57 */
58 public function lateCollect()
59 {
60 if (null !== $this->stopwatch && isset($this->data['token'])) {
61 $this->setEvents($this->stopwatch->getSectionEvents($this->data['token']));
62 }
63 unset($this->data['token']);
64 }
65 /**
66 * @param StopwatchEvent[] $events The request events
67 */
68 public function setEvents(array $events)
69 {
70 foreach ($events as $event) {
71 $event->ensureStopped();
72 }
73 $this->data['events'] = $events;
74 }
75 /**
76 * @return StopwatchEvent[]
77 */
78 public function getEvents() : array
79 {
80 return $this->data['events'];
81 }
82 /**
83 * Gets the request elapsed time.
84 */
85 public function getDuration() : float
86 {
87 if (!isset($this->data['events']['__section__'])) {
88 return 0;
89 }
90 $lastEvent = $this->data['events']['__section__'];
91 return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime();
92 }
93 /**
94 * Gets the initialization time.
95 *
96 * This is the time spent until the beginning of the request handling.
97 */
98 public function getInitTime() : float
99 {
100 if (!isset($this->data['events']['__section__'])) {
101 return 0;
102 }
103 return $this->data['events']['__section__']->getOrigin() - $this->getStartTime();
104 }
105 public function getStartTime() : float
106 {
107 return $this->data['start_time'];
108 }
109 public function isStopwatchInstalled() : bool
110 {
111 return $this->data['stopwatch_installed'];
112 }
113 /**
114 * {@inheritdoc}
115 */
116 public function getName() : string
117 {
118 return 'time';
119 }
120 }
121