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

StoreProductRequest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
wmc 10
eloc 27
dl 0
loc 64
ccs 16
cts 26
cp 0.6153
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A setType() 0 5 1
A __construct() 0 4 1
A setName() 0 5 1
A toArray() 0 24 5
A getType() 0 3 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 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