File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
src/Symfony/Component/Stopwatch Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 11CHANGELOG
22=========
33
4+ 7.2
5+ ---
6+
7+ * Add ` getRootSectionEvents() ` method and ` ROOT ` constant to ` Stopwatch `
8+
495.2
510---
611
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ class_exists(Section::class);
2323 */
2424class Stopwatch implements ResetInterface
2525{
26+ public const ROOT = '__root__ ' ;
27+
2628 /**
2729 * @var Section[]
2830 */
@@ -138,14 +140,24 @@ public function getEvent(string $name): StopwatchEvent
138140 */
139141 public function getSectionEvents (string $ id ): array
140142 {
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 () ?? [];
142154 }
143155
144156 /**
145157 * Resets the stopwatch to its original state.
146158 */
147159 public function reset (): void
148160 {
149- $ this ->sections = $ this ->activeSections = [' __root__ ' => new Section (null , $ this ->morePrecision )];
161+ $ this ->sections = $ this ->activeSections = [self :: ROOT => new Section (null , $ this ->morePrecision )];
150162 }
151163}
You can’t perform that action at this time.
0 commit comments