Completed
Push — master ( 9a2061...9f070b )
by Andrii
06:46
created

YearPeriod::countPeriodsPassed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\charge\modifiers\addons;
12
13
use DateTimeImmutable;
14
15
/**
16
 * Year Period addon.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
class YearPeriod extends Period
21
{
22
    public function countPeriodsPassed(DateTimeImmutable $since, DateTimeImmutable $time)
23
    {
24
        $diff = $time->diff($since);
25
26
        return $diff->y / $this->value;
27
    }
28
}
29