| @@ 9-40 (lines=32) @@ | ||
| 6 | ||
| 7 | use PH\Bundle\SubscriptionBundle\Helper\DateTimeHelperInterface; | |
| 8 | ||
| 9 | final class DateTimeHelperMock implements DateTimeHelperInterface | |
| 10 | { | |
| 11 | /** | |
| 12 | * @inheritdoc} | |
| 13 | */ | |
| 14 | public function getDate(int $day, int $months = 0): \DateTimeInterface | |
| 15 |     { | |
| 16 |         $date = new \DateTime(date('2017-10-'.$day)); | |
| 17 | ||
| 18 |         if (0 !== $months) { | |
| 19 |             $date->modify(sprintf('+%d months', $months)); | |
| 20 | } | |
| 21 | ||
| 22 | return $date; | |
| 23 | } | |
| 24 | ||
| 25 | /** | |
| 26 | * @inheritdoc} | |
| 27 | */ | |
| 28 | public function getFormattedDate(int $day, int $months = 0, $format = 'Y-m-d'): string | |
| 29 |     { | |
| 30 | return $this->getDate($day, $months)->format($format); | |
| 31 | } | |
| 32 | ||
| 33 | /** | |
| 34 | * @inheritdoc} | |
| 35 | */ | |
| 36 | public function getCurrentDateTime(): \DateTimeInterface | |
| 37 |     { | |
| 38 |         return new \DateTime(date('2017-10-09')); | |
| 39 | } | |
| 40 | } | |
| 41 | ||
| @@ 7-38 (lines=32) @@ | ||
| 4 | ||
| 5 | namespace PH\Bundle\SubscriptionBundle\Helper; | |
| 6 | ||
| 7 | final class DateTimeHelper implements DateTimeHelperInterface | |
| 8 | { | |
| 9 | /** | |
| 10 | * @inheritdoc} | |
| 11 | */ | |
| 12 | public function getDate(int $day, int $months = 0): \DateTimeInterface | |
| 13 |     { | |
| 14 |         $date = new \DateTime(date('Y-m-'.$day)); | |
| 15 | ||
| 16 |         if (0 !== $months) { | |
| 17 |             $date->modify(sprintf('+%d months', $months)); | |
| 18 | } | |
| 19 | ||
| 20 | return $date; | |
| 21 | } | |
| 22 | ||
| 23 | /** | |
| 24 | * @inheritdoc} | |
| 25 | */ | |
| 26 | public function getFormattedDate(int $day, int $months = 0, $format = 'Y-m-d'): string | |
| 27 |     { | |
| 28 | return $this->getDate($day, $months)->format($format); | |
| 29 | } | |
| 30 | ||
| 31 | /** | |
| 32 | * @inheritdoc} | |
| 33 | */ | |
| 34 | public function getCurrentDateTime(): \DateTimeInterface | |
| 35 |     { | |
| 36 | return new \DateTime(); | |
| 37 | } | |
| 38 | } | |
| 39 | ||