CodeRequest::buildHeaders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Request;
6
7
use Kerox\Messenger\Helper\UtilityTrait;
8
9
class CodeRequest extends AbstractRequest
10
{
11
    use UtilityTrait;
12
13
    /**
14
     * @var int
15
     */
16
    protected $imageSize;
17
18
    /**
19
     * @var string
20
     */
21
    protected $codeType;
22
23
    /**
24
     * @var string|null
25
     */
26
    protected $ref;
27
28
    /**
29
     * CodeRequest constructor.
30
     */
31 1
    public function __construct(string $pageToken, int $imageSize, string $codeType, ?string $ref = null)
32
    {
33 1
        parent::__construct($pageToken);
34
35 1
        $this->imageSize = $imageSize;
36 1
        $this->codeType = $codeType;
37 1
        $this->ref = $ref;
38 1
    }
39
40 1
    protected function buildHeaders(): array
41
    {
42
        return [
43 1
            'Content-Type' => 'application/json',
44
        ];
45
    }
46
47 1
    protected function buildBody(): array
48
    {
49
        $body = [
50 1
            'type' => $this->codeType,
51 1
            'image_size' => $this->imageSize,
52
            'data' => [
53 1
                'ref' => $this->ref,
54
            ],
55
        ];
56
57 1
        return $this->arrayFilter($body);
58
    }
59
}
60