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