Passed
Push — 2.x ( 410808...ae0f7c )
by Darío
49s queued 11s
created

UpdateProductRequest::getProductId()   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\HasProductCategory;
6
use PaymentGateway\PayPalSdk\Products\Concerns\HasProductDescription;
7
use PaymentGateway\PayPalSdk\Products\Concerns\HasHomeUrl;
8
use PaymentGateway\PayPalSdk\Products\Concerns\HasImageUrl;
9
10
class UpdateProductRequest
11
{
12
    use HasProductDescription;
13
    use HasProductCategory;
14
    use HasImageUrl;
15
    use HasHomeUrl;
16
17
    protected string $productId;
18
19 5
    public function __construct(string $productId)
20
    {
21 5
        $this->productId = $productId;
22 5
    }
23
24 3
    public function getProductId(): string
25
    {
26 3
        return $this->productId;
27
    }
28
29 1
    public function setProductId(string $productId): self
30
    {
31 1
        $this->productId = $productId;
32
33 1
        return $this;
34
    }
35
36 5
    public function toArray(): array
37
    {
38 5
        $request = [];
39
40 5
        if ($this->productDescription ?? null) {
41 3
            $request[] = [
42 3
                'op' => 'replace',
43 3
                'path' => '/description',
44 3
                'value' => $this->productDescription
45
            ];
46
        }
47
48 5
        if ($this->productCategory ?? null) {
49 3
            $request[] = [
50 3
                'op' => 'replace',
51 3
                'path' => '/category',
52 3
                'value' => $this->productCategory
53
            ];
54
        }
55
56 5
        if ($this->imageUrl ?? null) {
57 3
            $request[] = [
58 3
                'op' => 'replace',
59 3
                'path' => '/image_url',
60 3
                'value' => $this->imageUrl
61
            ];
62
        }
63
64 5
        if ($this->homeUrl ?? null) {
65 3
            $request[] = [
66 3
                'op' => 'replace',
67 3
                'path' => '/home_url',
68 3
                'value' => $this->homeUrl
69
            ];
70
        }
71
72 5
        return $request;
73
    }
74
}
75