Skip to content

Commit 13a5e47

Browse files
committed
feature #37703 Update StopwatchPeriod.php (ThomasLandauer)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- Update StopwatchPeriod.php Adding `__toString()`, analogous to [`StopwatchEvent`](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Stopwatch/StopwatchEvent.php#L242) | Q | A | ------------- | --- | Branch? | master for features | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | | License | MIT | Doc PR | none Commits ------- d3c2911 Update StopwatchPeriod.php
2 parents 79bc5b7 + d3c2911 commit 13a5e47

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Symfony/Component/Stopwatch/StopwatchEvent.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,7 @@ private function formatTime(float $time): float
236236
return round($time, 1);
237237
}
238238

239-
/**
240-
* @return string
241-
*/
242-
public function __toString()
239+
public function __toString(): string
243240
{
244241
return sprintf('%s: %.2F MiB - %d ms', $this->getCategory(), $this->getMemory() / 1024 / 1024, $this->getDuration());
245242
}

src/Symfony/Component/Stopwatch/StopwatchPeriod.php

+5
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,9 @@ public function getMemory()
7373
{
7474
return $this->memory;
7575
}
76+
77+
public function __toString(): string
78+
{
79+
return sprintf('%.2F MiB - %d ms', $this->getMemory() / 1024 / 1024, $this->getDuration());
80+
}
7681
}

0 commit comments

Comments
 (0)