AbstractDatetimeProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
dl 0
loc 18
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A estimatePeriodEndAt() 0 10 2
1
<?php
2
3
namespace Recurrence\Provider;
4
5
use Recurrence\Model\Recurrence;
6
7
abstract class AbstractDatetimeProvider
8
{
9
    public function estimatePeriodEndAt(Recurrence $recurrence): ?\Datetime
10
    {
11 1
        $periodEndAt = $recurrence->getPeriodEndAt();
12
13 1
        if ($recurrence->hasCount()) {
14 1
            $periodEndAt = clone $recurrence->getPeriodStartAt();
15 1
            $periodEndAt->modify(str_replace('1', ($recurrence->getCount()*$recurrence->getInterval()), $recurrence->getFrequency()->convertToDateTimeFormat()));
16
        }
17
18 1
        return $periodEndAt;
19
    }
20
21
    /**
22
     * @return array<\DateTime>
23
     */
24
    abstract public function provide(Recurrence $recurrence): array;
25
}
26