Passed
Push — master ( cbdbb3...bd81e8 )
by Jhao
01:58
created

NormalizePhoneRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 27
ccs 12
cts 12
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A one() 0 7 1
A addPhone() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests;
6
7
use Appwilio\RussianPostSDK\Dispatching\DataAware;
8
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable;
9
10
final class NormalizePhoneRequest implements Arrayable
11
{
12
    use DataAware;
13
14 1
    public static function one(string $phone, ?string $area = null, ?string $place = null, ?string $region = null): self
15
    {
16 1
        $request = new self();
17
18 1
        $request->addPhone(...\func_get_args());
0 ignored issues
show
Bug introduced by
func_get_args() is expanded, but the parameter $phone of Appwilio\RussianPostSDK\...honeRequest::addPhone() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        $request->addPhone(/** @scrutinizer ignore-type */ ...\func_get_args());
Loading history...
19
20 1
        return $request;
21
    }
22
23 1
    public function addPhone(string $phone, ?string $area = null, ?string $place = null, ?string $region = null): void
24
    {
25 1
        $this->data[] = \array_merge(
26
            [
27 1
                'id'             => \sha1($phone),
28 1
                'original-phone' => $phone,
29
            ],
30 1
            \array_filter(\compact('area', 'place', 'region'))
31
        );
32 1
    }
33
34 1
    public function toArray(): array
35
    {
36 1
        return $this->data;
37
    }
38
}
39