Search   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 9
eloc 24
c 2
b 1
f 1
dl 0
loc 94
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A body() 0 7 1
A setDefaults() 0 9 3
A setRecipientType() 0 5 1
A setRefId() 0 5 1
A setType() 0 5 1
A getUrl() 0 3 1
A setRecipient() 0 5 1
1
<?php
2
3
namespace TarfinLabs\Netgsm\Iys\Requests;
4
5
class Search
6
{
7
    protected string $url = 'iys/search';
8
9
    protected string $type;
10
11
    protected string $recipient;
12
13
    protected string $recipientType;
14
15
    protected string $refId;
16
17
    /**
18
     * @param string $type
19
     * @return $this
20
     */
21
    public function setType(string $type): self
22
    {
23
        $this->type = $type;
24
25
        return $this;
26
    }
27
28
    /**
29
     * @param string $recipient
30
     * @return $this
31
     */
32
    public function setRecipient(string $recipient): self
33
    {
34
        $this->recipient = $recipient;
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param string $recipientType
41
     * @return $this
42
     */
43
    public function setRecipientType(string $recipientType): self
44
    {
45
        $this->recipientType = $recipientType;
46
47
        return $this;
48
    }
49
50
    /**
51
     * @param string $refId
52
     * @return $this
53
     */
54
    public function setRefId(string $refId): self
55
    {
56
        $this->refId = $refId;
57
58
        return $this;
59
    }
60
61
    /**
62
     * @param array $defaults
63
     * @return $this
64
     */
65
    public function setDefaults(array $defaults): self
66
    {
67
        foreach ($defaults as $key => $value) {
68
            if (method_exists($this, 'set'.ucfirst($key))) {
69
                call_user_func([$this, 'set'.ucfirst($key)], $value);
70
            }
71
        }
72
73
        return $this;
74
    }
75
76
    /**
77
     * Get request body.
78
     *
79
     * @return array
80
     */
81
    public function body(): array
82
    {
83
        return [
84
            'type'              => $this->type ?? null,
85
            'recipient'         => $this->recipient ?? null,
86
            'recipientType'     => $this->recipientType ?? null,
87
            'refid'             => $this->refId ?? null,
88
        ];
89
    }
90
91
    /**
92
     * Get request url.
93
     *
94
     * @return string
95
     */
96
    public function getUrl(): string
97
    {
98
        return $this->url;
99
    }
100
}
101