Passed
Push — 2.x ( 61c545 )
by Darío
07:41
created

StoreProductRequest::getProductName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Products\Requests;
4
5
use PaymentGateway\PayPalSdk\Products\Concerns\HasProductCategory;
6
use PaymentGateway\PayPalSdk\Products\Concerns\HasDescription;
7
use PaymentGateway\PayPalSdk\Products\Concerns\HasHomeUrl;
8
use PaymentGateway\PayPalSdk\Products\Concerns\HasImageUrl;
9
use PaymentGateway\PayPalSdk\Products\Constants\ProductType;
10
11
class StoreProductRequest
12
{
13
    use HasDescription;
14
    use HasProductCategory;
15
    use HasImageUrl;
16
    use HasHomeUrl;
17
18
    protected string $productName;
19
20
    /**
21
     * @var string
22
     * @see ProductType
23
     */
24
    protected string $productType;
25
26 11
    public function __construct(string $name, string $productType)
27
    {
28 11
        $this->productName = $name;
29 11
        $this->productType = $productType;
30 11
    }
31
32
    public function getProductName(): string
33
    {
34
        return $this->productName;
35
    }
36
37
    public function setProductName(string $productName): self
38
    {
39
        $this->productName = $productName;
40
41
        return $this;
42
    }
43
44
    public function getProductType(): string
45
    {
46
        return $this->productType;
47
    }
48
49
    public function setProductType(string $productType): self
50
    {
51
        $this->productType = $productType;
52
53
        return $this;
54
    }
55
56 11
    public function toArray(): array
57
    {
58
        $request = [
59 11
            'name' => $this->productName,
60 11
            'type' => $this->productType,
61
        ];
62
63 11
        if ($this->description ?? null) {
64 10
            $request['description'] = $this->description;
65
        }
66
67 11
        if ($this->productCategory ?? null) {
68 10
            $request['category'] = $this->productCategory;
69
        }
70
71 11
        if ($this->imageUrl ?? null) {
72 10
            $request['image_url'] = $this->imageUrl;
73
        }
74
75 11
        if ($this->homeUrl ?? null) {
76 10
            $request['home_url'] = $this->homeUrl;
77
        }
78
79 11
        return $request;
80
    }
81
}
82