Completed
Push — IncomprehensibleFinder/base ( 32b764...818385 )
by Albert
02:05
created

Person   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 30
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A name() 0 4 1
A birthDate() 0 4 1
A equals() 0 5 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Kata\Algorithm\Model;
6
7
use DateTime;
8
9
final class Person
10
{
11
    /** @var string */
12
    private $name;
13
14
    /** @var DateTime */
15
    private $birth_date;
16
17 6
    public function __construct($a_name, DateTime $a_birth_date)
18
    {
19 6
        $this->name = $a_name;
20 6
        $this->birth_date = $a_birth_date;
21 6
    }
22
23
    public function name(): string
24
    {
25
        return $this->name;
26
    }
27
28 4
    public function birthDate(): DateTime
29
    {
30 4
        return $this->birth_date;
31
    }
32
33 5
    public function equals(Person $other_person)
34
    {
35 5
        return $this->name === $other_person->name
36 5
            && $this->birth_date->getTimestamp() === $other_person->birth_date->getTimestamp();
37
    }
38
}
39