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

AbstractRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 52
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
buildHeaders() 0 1 ?
buildBody() 0 1 ?
A buildQuery() 0 6 1
A build() 0 10 1
1
<?php
2
namespace Kerox\Messenger\Request;
3
4
abstract class AbstractRequest
5
{
6
7
    /**
8
     * @var string
9
     */
10
    protected $pageToken;
11
12
    /**
13
     * AbstractRequest constructor.
14
     *
15
     * @param string $pageToken
16
     */
17
    public function __construct(string $pageToken)
18
    {
19
        $this->pageToken = $pageToken;
20
    }
21
22
    /**
23
     * @return mixed
24
     */
25
    abstract protected function buildHeaders();
26
27
    /**
28
     * @return mixed
29
     */
30
    abstract protected function buildBody();
31
32
    /**
33
     * @return mixed
34
     */
35
    protected function buildQuery(): array
36
    {
37
        return [
38
            'access_token' => $this->pageToken
39
        ];
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function build(): array
46
    {
47
        $request = [
48
            'headers' => $this->buildHeaders(),
49
            'json' => $this->buildBody(),
50
            'query' => $this->buildQuery(),
51
        ];
52
53
        return array_filter($request);
54
    }
55
}
56