Completed
Push — master ( 7d972a...3baf5c )
by Andrii
02:11
created

MonthPeriod::countPeriodsPassed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
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
 * Month Period addon.
17
 *
18
 * @author Andrii Vasyliev <[email protected]>
19
 */
20
class MonthPeriod extends Period
21
{
22 4
    public static function countPeriodsPassed(DateTimeImmutable $since, DateTimeImmutable $time)
23
    {
24 4
        $diff = $time->diff($since);
25
26 4
        return $diff->m + $diff->y*12;
27
    }
28
}
29