Passed
Pull Request — main (#8)
by Alex
03:11 queued 01:35
created

PhoneNumber   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 32
rs 10
c 0
b 0
f 0
ccs 15
cts 15
cp 1
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A number() 0 3 1
A create() 0 5 1
A prefix() 0 3 1
A equal() 0 4 2
1
<?php
2
3
namespace StraTDeS\VO\Single;
4
5
class PhoneNumber
6
{
7
    private string $prefix;
8
    private string $number;
9
10 6
    private function __construct(string $prefix, string $number)
11
    {
12 6
        $this->prefix = $prefix;
13 6
        $this->number = $number;
14 6
    }
15
16 6
    public static function create(string $prefix, string $number): PhoneNumber
17
    {
18 6
        $prefix = str_replace([' ', '+'], '', $prefix);
19 6
        $number = str_replace(' ', '', $number);
20 6
        return new self($prefix, $number);
21
    }
22
23 1
    public function prefix(): string
24
    {
25 1
        return $this->prefix;
26
    }
27
28 1
    public function number(): string
29
    {
30 1
        return $this->number;
31
    }
32
33 3
    public function equal(PhoneNumber $phoneNumber): bool
34
    {
35 3
        return $this->prefix == $phoneNumber->prefix &&
36 3
            $this->number == $phoneNumber->number;
37
    }
38
}
39