Skip to content
Merged
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
19 changes: 19 additions & 0 deletions src/FormattingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@
/**
* Returns the quarter
*
* Deprecated 3.3.0: The $range parameter is deprecated. Use toQuarterRange() for quarter ranges.
*
* @param bool $range Range.
* @return array|int 1, 2, 3, or 4 quarter of year or array if $range true
*/
Expand All @@ -246,7 +248,24 @@
return $quarter;
}

trigger_error(
'Using toQuarter() with `$range=true` is deprecated. Use `toQuarterRange()` instead.',
E_USER_DEPRECATED

Check failure on line 253 in src/FormattingTrait.php

View workflow job for this annotation

GitHub Actions / cs-stan / Coding Standard & Static Analysis

Multi-line function calls must have a trailing comma after the last parameter.
);

return $this->toQuarterRange();
}

/**
* Returns the quarter range
*
* @return array<string> Array with start and end date of quarter in Y-m-d format
*/
public function toQuarterRange(): array
{
$quarter = (int)ceil((int)$this->format('m') / 3);
$year = $this->format('Y');

switch ($quarter) {
case 1:
return [$year . '-01-01', $year . '-03-31'];
Expand Down
Loading