Completed
Push — master ( 3347ae...8ec7fe )
by Romain
9s
created

SendRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 77
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A buildHeaders() 0 6 1
A buildBody() 0 13 1
A buildQuery() 0 4 1
1
<?php
2
namespace Kerox\Messenger\Request;
3
4
class SendRequest extends AbstractRequest
5
{
6
7
    /**
8
     * @var string
9
     */
10
    protected $recipient;
11
12
    /**
13
     * @var null|string|\Kerox\Messenger\Model\Message
14
     */
15
    protected $message;
16
17
    /**
18
     * @var null|string
19
     */
20
    protected $senderAction;
21
22
    /**
23
     * @var null|string
24
     */
25
    protected $notificationType;
26
27
    /**
28
     * Request constructor.
29
     *
30
     * @param string $pageToken
31
     * @param string $recipient
32
     * @param $message
33
     * @param $senderAction
34
     * @param $notificationType
35
     */
36
    public function __construct(string $pageToken, string $recipient, $message, $senderAction, $notificationType)
37
    {
38
        parent::__construct($pageToken);
39
40
        $this->recipient = $recipient;
41
        $this->message = $message;
42
        $this->senderAction = $senderAction;
43
        $this->notificationType = $notificationType;
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    protected function buildHeaders(): array
50
    {
51
        return [
52
            'Content-Type' => 'application/json',
53
        ];
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    protected function buildBody(): array
60
    {
61
        $body = [
62
            'recipient' => [
63
                'id' => $this->recipient,
64
            ],
65
            'message' => $this->message,
66
            'sender_action' => $this->senderAction,
67
            'notification_type' => $this->notificationType,
68
        ];
69
70
        return array_filter($body);
71
    }
72
73
    /**
74
     * @return array
75
     */
76
    protected function buildQuery(): array
77
    {
78
        parent::buildQuery();
79
    }
80
}
81