Completed
Pull Request — master (#18)
by Samuel
03:55
created

AbstractDatetimeProvider::estimatePeriodEndAt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Recurrence\Provider;
4
5
use Recurrence\Model\Recurrence;
6
7
/**
8
 * Class AbstractDatetimeProvider
9
 * @package Recurrence\Provider
10
 */
11
abstract class AbstractDatetimeProvider
12
{
13
    /**
14
     * @param Recurrence $recurrence
15
     * @return \Datetime
16
     */
17
    public function estimatePeriodEndAt(Recurrence $recurrence)
18
    {
19
        $periodEndAt = $recurrence->getPeriodEndAt();
20
21
        if ($recurrence->hasCount()) {
22
            $periodEndAt = clone $recurrence->getPeriodStartAt();
23
            $periodEndAt->modify(str_replace('1', ($recurrence->getCount()*$recurrence->getInterval()), $recurrence->getFrequency()->convertToDateTimeFormat()));
24
        }
25
26
        return $periodEndAt;
27
    }
28
29
    /**
30
     * @param Recurrence $recurrence
31
     * @return array<\DateTime>
32
     */
33
    abstract function provide(Recurrence $recurrence);
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
}
35