Skip to content

[Stopwatch] Add getLastPeriod method to StopwatchEvent #54855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Symfony/Component/Stopwatch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

7.2
---

* Add method `getLastPeriod()` to `StopwatchEvent`

5.2
---

Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/Stopwatch/StopwatchEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ public function getPeriods(): array
return $this->periods;
}

/**
* Gets the last event period.
*/
public function getLastPeriod(): ?StopwatchPeriod
{
if ([] === $this->periods) {
return null;
}

return $this->periods[array_key_last($this->periods)];
}

/**
* Gets the relative time of the start of the first period in milliseconds.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Stopwatch/StopwatchPeriod.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\Stopwatch;

/**
* Represents an Period for an Event.
* Represents a Period for an Event.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
Expand Down
Loading