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

StartDateProvider::__construct()   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 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PH\Bundle\SubscriptionBundle\Provider;
6
7
use PH\Bundle\SubscriptionBundle\Helper\DateTimeHelperInterface;
8
9
final class StartDateProvider implements StartDateProviderInterface
10
{
11
    private $dateTimeHelper;
12
13
    public function __construct(DateTimeHelperInterface $dateTimeHelper)
14
    {
15
        $this->dateTimeHelper = $dateTimeHelper;
16
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function getStartDates(): array
22
    {
23
        $now = $this->dateTimeHelper->getCurrentDateTime();
24
        $dates = [];
25
26 View Code Duplication
        if ($now < $this->dateTimeHelper->getDate(1)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
27
            $dates[$this->dateTimeHelper->getFormattedDate(1)] = $this->dateTimeHelper->getFormattedDate(1);
28
        }
29
30 View Code Duplication
        if ($now < $this->dateTimeHelper->getDate(15)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
31
            $dates[$this->dateTimeHelper->getFormattedDate(15)] = $this->dateTimeHelper->getFormattedDate(15);
32
        }
33
34
        return array_merge($dates, [
35
            $this->dateTimeHelper->getFormattedDate(1, 1) => $this->dateTimeHelper->getFormattedDate(1, 1),
36
            $this->dateTimeHelper->getFormattedDate(15, 1) => $this->dateTimeHelper->getFormattedDate(15, 1),
37
        ]);
38
    }
39
}
40