Completed
Push — master ( 3dc30b...6a0dc0 )
by Jhao
04:34 queued 02:01
created

NormalizePhoneRequest::one()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests;
6
7
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable;
8
9
final class NormalizePhoneRequest implements Arrayable
10
{
11
    private $items = [];
12
13
    public static function one(string $phone, ?string $area = null, ?string $place = null, ?string $region = null): self
14
    {
15
        $request = new self();
16
17
        $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

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