File tree 2 files changed +19
-2
lines changed
src/Symfony/Component/Stopwatch
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
1
CHANGELOG
2
2
=========
3
3
4
+ 7.2
5
+ ---
6
+
7
+ * Add ` getRootSectionEvents() ` method and ` ROOT ` constant to ` Stopwatch `
8
+
4
9
5.2
5
10
---
6
11
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ class_exists(Section::class);
23
23
*/
24
24
class Stopwatch implements ResetInterface
25
25
{
26
+ public const ROOT = '__root__ ' ;
27
+
26
28
/**
27
29
* @var Section[]
28
30
*/
@@ -138,14 +140,24 @@ public function getEvent(string $name): StopwatchEvent
138
140
*/
139
141
public function getSectionEvents (string $ id ): array
140
142
{
141
- return isset ($ this ->sections [$ id ]) ? $ this ->sections [$ id ]->getEvents () : [];
143
+ return $ this ->sections [$ id ]->getEvents () ?? [];
144
+ }
145
+
146
+ /**
147
+ * Gets all events for the root section.
148
+ *
149
+ * @return StopwatchEvent[]
150
+ */
151
+ public function getRootSectionEvents (): array
152
+ {
153
+ return $ this ->sections [self ::ROOT ]->getEvents () ?? [];
142
154
}
143
155
144
156
/**
145
157
* Resets the stopwatch to its original state.
146
158
*/
147
159
public function reset (): void
148
160
{
149
- $ this ->sections = $ this ->activeSections = [' __root__ ' => new Section (null , $ this ->morePrecision )];
161
+ $ this ->sections = $ this ->activeSections = [self :: ROOT => new Section (null , $ this ->morePrecision )];
150
162
}
151
163
}
You can’t perform that action at this time.
0 commit comments