Completed
Push — master ( 823f1c...5ca85f )
by Rafał
08:28
created

DateTimeHelper::getCurrentDay()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PH\Bundle\SubscriptionBundle\Helper;
6
7 View Code Duplication
final class DateTimeHelper implements DateTimeHelperInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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