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

AbstractDatetimeProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A estimatePeriodEndAt() 0 11 2
provide() 0 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