Passed
Push — master ( 745713...423bfb )
by Darío
07:06 queued 04:58
created

UpdateProductRequest::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Products\Requests;
4
5
use PaymentGateway\PayPalSdk\Products\Concerns\HasCategory;
6
use PaymentGateway\PayPalSdk\Products\Concerns\HasDescription;
7
use PaymentGateway\PayPalSdk\Products\Concerns\HasHomeUrl;
8
use PaymentGateway\PayPalSdk\Products\Concerns\HasImageUrl;
9
10
class UpdateProductRequest
11
{
12
    use HasDescription;
13
    use HasCategory;
14
    use HasImageUrl;
15
    use HasHomeUrl;
16
17
    protected string $id;
18
19 1
    public function __construct(string $id)
20
    {
21 1
        $this->id = $id;
22 1
    }
23
24 1
    public function getId(): string
25
    {
26 1
        return $this->id;
27
    }
28
29 1
    public function toArray(): array
30
    {
31 1
        $request = [];
32
33 1
        if ($this->description) {
34 1
            $request[] = [
35 1
                'op' => 'replace',
36 1
                'path' => '/description',
37 1
                'value' => $this->description
38
            ];
39
        }
40
41 1
        if ($this->category) {
42 1
            $request[] = [
43 1
                'op' => 'replace',
44 1
                'path' => '/category',
45 1
                'value' => $this->category
46
            ];
47
        }
48
49 1
        if ($this->imageUrl) {
50 1
            $request[] = [
51 1
                'op' => 'replace',
52 1
                'path' => '/image_url',
53 1
                'value' => $this->imageUrl
54
            ];
55
        }
56
57 1
        if ($this->homeUrl) {
58 1
            $request[] = [
59 1
                'op' => 'replace',
60 1
                'path' => '/home_url',
61 1
                'value' => $this->homeUrl
62
            ];
63
        }
64
65 1
        return $request;
66
    }
67
}
68