StoreProductRequest   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 61.53%

Importance

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

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 getType() 0 3 1
A toArray() 0 24 5
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 10
    public function __construct(string $name, string $type)
21
    {
22 10
        $this->name = $name;
23 10
        $this->type = $type;
24 10
    }
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 10
    public function toArray(): array
51
    {
52
        $request = [
53 10
            'name' => $this->name,
54 10
            'type' => $this->type,
55
        ];
56
57 10
        if ($this->description ?? null) {
58 9
            $request['description'] = $this->description;
59
        }
60
61 10
        if ($this->category ?? null) {
62 9
            $request['category'] = $this->category;
63
        }
64
65 10
        if ($this->imageUrl ?? null) {
66 9
            $request['image_url'] = $this->imageUrl;
67
        }
68
69 10
        if ($this->homeUrl ?? null) {
70 9
            $request['home_url'] = $this->homeUrl;
71
        }
72
73 10
        return $request;
74
    }
75
}
76