Adding the boundaryType to Period named constructors ?
nyamsprod opened this issue · comments
ignace nyamagana butera commented
Feature Request
Q | A |
---|---|
New Feature | yes |
BC Break | no |
Proposal
Currently most Period
named constructors do not take into consideration the boundary type.
This proposal is to simplify and normalized Period
object instantiation.
Instead of doing
$period = Period::fromMonth(2019, 3)->withBoundaryType(Period::EXCLUDE_ALL);
you will be able to do
$period = Period::fromMonth(2019, 3, Period::EXCLUDE_ALL);
This feature if accepted will land in the next feature release (ie 3.9.0
as the time of writing)
The affected named constructors are the following:
Period::fromYear(int $year): Period;
Period::fromIsoYear(int $year): Period;
Period::fromSemester(int $year, int $semester = 1): Period;
Period::fromQuarter(int $year, int $quarter = 1): Period;
Period::fromMonth(int $year, int $month = 1): Period;
Period::fromIsoWeek(int $year, int $week = 1): Period;
Period::fromDay(int $year, int $month = 1, int $day = 1): Period;
their new signature will be
Period::fromYear(int $year, string $boundaryType = self::INCLUDE_START_EXCLUDE_END): Period;
Period::fromIsoYear(int $year, string $boundaryType = self::INCLUDE_START_EXCLUDE_END): Period;
Period::fromSemester(int $year, int $semester = 1, string $boundaryType = self::INCLUDE_START_EXCLUDE_END): Period;
Period::fromQuarter(int $year, int $quarter = 1, string $boundaryType = self::INCLUDE_START_EXCLUDE_END): Period;
Period::fromMonth(int $year, int $month = 1, string $boundaryType = self::INCLUDE_START_EXCLUDE_END): Period;
Period::fromIsoWeek(int $year, int $week = 1, string $boundaryType = self::INCLUDE_START_EXCLUDE_END): Period;
Period::fromDay(int $year, int $month = 1, int $day = 1, string $boundaryType = self::INCLUDE_START_EXCLUDE_END): Period;
The default value is chosen to avoid BC break.
Of Note: the addition of the boundary Type has already be made for the Datepoint
class.