Completed
Push — IncomprehensibleFinder/Edu-Chr... ( 0d3d24...6fe578 )
by Eduard
03:21
created

AgeComparatorResult   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A calculatedAgeDifference() 0 5 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Kata\Algorithm;
6
7
final class AgeComparatorResult
8
{
9
    /** @var Person */
10
    public $person_one;
11
12
    /** @var Person */
13
    public $person_two;
14
15
    /** @var int */
16
    public $age_difference;
17
18 4
    public function __construct(
19
        Person $a_person_one,
20
        Person $a_person_two
21
    ) {
22 4
        $this->person_one = $a_person_one;
23 4
        $this->person_two = $a_person_two;
24
25 4
        $this->calculatedAgeDifference();
26 4
    }
27
28 4
    private function calculatedAgeDifference(): void
29
    {
30 4
        $this->age_difference = $this->person_two->birthDate()->getTimestamp()
31 4
            - $this->person_one->birthDate()->getTimestamp();
32 4
    }
33
}
34