mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DX: Rolling date: allow to receive a null parameter (RollingDate)
When receiving a null parameter (a null rolling date), it will return null
This commit is contained in:
parent
4a5ac170ba
commit
393e59e22b
5
.changes/unreleased/DX-20230629-160029.yaml
Normal file
5
.changes/unreleased/DX-20230629-160029.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
kind: DX
|
||||||
|
body: 'Rolling Date: can receive a null parameter'
|
||||||
|
time: 2023-06-29T16:00:29.664814895+02:00
|
||||||
|
custom:
|
||||||
|
Issue: ""
|
@ -18,8 +18,12 @@ use UnexpectedValueException;
|
|||||||
|
|
||||||
class RollingDateConverter implements RollingDateConverterInterface
|
class RollingDateConverter implements RollingDateConverterInterface
|
||||||
{
|
{
|
||||||
public function convert(RollingDate $rollingDate): DateTimeImmutable
|
public function convert(?RollingDate $rollingDate): ?DateTimeImmutable
|
||||||
{
|
{
|
||||||
|
if (null === $rollingDate) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($rollingDate->getRoll()) {
|
switch ($rollingDate->getRoll()) {
|
||||||
case RollingDate::T_MONTH_CURRENT_START:
|
case RollingDate::T_MONTH_CURRENT_START:
|
||||||
return $this->toBeginOfMonth($rollingDate->getPivotDate());
|
return $this->toBeginOfMonth($rollingDate->getPivotDate());
|
||||||
|
@ -15,5 +15,9 @@ use DateTimeImmutable;
|
|||||||
|
|
||||||
interface RollingDateConverterInterface
|
interface RollingDateConverterInterface
|
||||||
{
|
{
|
||||||
public function convert(RollingDate $rollingDate): DateTimeImmutable;
|
/**
|
||||||
|
* @param RollingDate|null $rollingDate
|
||||||
|
* @return ($rollingDate is null ? null : DateTimeImmutable)
|
||||||
|
*/
|
||||||
|
public function convert(?RollingDate $rollingDate): ?DateTimeImmutable;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user