Passed
Push — master ( 677674...195bf7 )
by Julien
04:05
created

Request::setWebhookURLTimeout()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TheCodingMachine\Gotenberg;
6
7
abstract class Request
8
{
9
    public const A3 = [11.7, 16.5];
10
    public const A4 = [8.27, 11.7];
11
    public const A5 = [5.8, 8.2];
12
    public const A6 = [4.1, 5.8];
13
    public const LETTER = [8.5, 11];
14
    public const LEGAL = [8.5, 14];
15
    public const TABLOID = [11, 17];
16
17
    public const NO_MARGINS = [0, 0, 0, 0];
18
    public const NORMAL_MARGINS = [1, 1, 1, 1];
19
    public const LARGE_MARGINS = [2, 2, 2, 2];
20
21
    private const RESULT_FILENAME = 'resultFilename';
22
    private const WAIT_TIMEOUT = 'waitTimeout';
23
    private const WEBHOOK_URL = 'webhookURL';
24
    private const WEBHOOK_URL_TIMEOUT = 'webhookURLTimeout';
25
26
    /** @var string|null */
27
    private $resultFilename;
28
29
    /** @var float|null */
30
    private $waitTimeout;
31
32
    /** @var string|null */
33
    private $webhookURL;
34
35
    /** @var float|null */
36
    private $webhookURLTimeout;
37
38
    /**
39
     * @return array<string,mixed>
40
     */
41
    public function getFormValues(): array
42
    {
43
        $values = [];
44
        if (! empty($this->resultFilename)) {
45
            $values[self::RESULT_FILENAME] = $this->resultFilename;
46
        }
47
        if ($this->waitTimeout !== null) {
48
            $values[self::WAIT_TIMEOUT] = $this->waitTimeout;
49
        }
50
        if (! empty($this->webhookURL)) {
51
            $values[self::WEBHOOK_URL] = $this->webhookURL;
52
        }
53
        if (! empty($this->webhookURLTimeout)) {
54
            $values[self::WEBHOOK_URL_TIMEOUT] = $this->webhookURLTimeout;
55
        }
56
57
        return $values;
58
    }
59
60
    public function setResultFilename(?string $resultFilename): void
61
    {
62
        $this->resultFilename = $resultFilename;
63
    }
64
65
    public function setWaitTimeout(?float $waitTimeout): void
66
    {
67
        $this->waitTimeout = $waitTimeout;
68
    }
69
70
    public function setWebhookURL(?string $webhookURL): void
71
    {
72
        $this->webhookURL = $webhookURL;
73
    }
74
75
    public function setWebhookURLTimeout(?float $webhookURLTimeout): void
76
    {
77
        $this->webhookURLTimeout = $webhookURLTimeout;
78
    }
79
}
80