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

StoreProductRequest::getType()   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
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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 StoreProductRequest
11
{
12
    use HasDescription;
13
    use HasCategory;
14
    use HasImageUrl;
15
    use HasHomeUrl;
16
17
    protected string $name;
18
    protected string $type;
19
20 8
    public function __construct(string $name, string $type)
21
    {
22 8
        $this->name = $name;
23 8
        $this->type = $type;
24 8
    }
25
26
    public function getName(): string
27
    {
28
        return $this->name;
29
    }
30
31
    public function setName(string $name): self
32
    {
33
        $this->name = $name;
34
35
        return $this;
36
    }
37
38
    public function getType(): string
39
    {
40
        return $this->type;
41
    }
42
43
    public function setType(string $type): self
44
    {
45
        $this->type = $type;
46
47
        return $this;
48
    }
49
50 8
    public function toArray(): array
51
    {
52
        $request = [
53 8
            'name' => $this->name,
54 8
            'type' => $this->type,
55
        ];
56
57 8
        if ($this->description) {
58 8
            $request['description'] = $this->description;
59
        }
60
61 8
        if ($this->category) {
62 8
            $request['category'] = $this->category;
63
        }
64
65 8
        if ($this->imageUrl) {
66 8
            $request['image_url'] = $this->imageUrl;
67
        }
68
69 8
        if ($this->homeUrl) {
70 8
            $request['home_url'] = $this->homeUrl;
71
        }
72
73 8
        return $request;
74
    }
75
}
76