Passed
Push — master ( 9dc2b5...745713 )
by Darío
03:33 queued 01:28
created

UpdateProductRequest::setId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Requests;
4
5
use PaymentGateway\PayPalSdk\Requests\Concerns\HasCategory;
6
use PaymentGateway\PayPalSdk\Requests\Concerns\HasDescription;
7
use PaymentGateway\PayPalSdk\Requests\Concerns\HasHomeUrl;
8
use PaymentGateway\PayPalSdk\Requests\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