Completed
Push — master ( c556fe...70cab5 )
by Julien
03:22
created

OfficeRequest::setPaperSize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace TheCodingMachine\Gotenberg;
4
5
final class OfficeRequest extends Request implements GotenbergRequestInterface
6
{
7
    /** @var Document[] */
8
    private $files;
9
10
    /** @var bool */
11
    private $landscape;
12
13
    /**
14
     * OfficeRequest constructor.
15
     * @param Document[] $files
16
     */
17
    public function __construct(array $files)
18
    {
19
        $this->files = $files;
20
    }
21
22
23
    /**
24
     * @return string
25
     */
26
    public function getPostURL(): string
27
    {
28
        return '/convert/office';
29
    }
30
31
    /**
32
     * @return array<string,mixed>
33
     */
34
    public function getFormValues(): array
35
    {
36
        $values = [];
37
        if (!empty($this->webhookURL)) {
38
            $values[self::WEBHOOK_URL] = $this->webhookURL;
39
        }
40
        $values[self::LANDSCAPE] = $this->landscape;
41
        return $values;
42
    }
43
44
    /**
45
     * @return array<string,Document>
46
     */
47
    public function getFormFiles(): array
48
    {
49
        $files = [];
50
        foreach ($this->files as $file) {
51
            $files[$file->getFileName()] = $file;
52
        }
53
        return $files;
54
    }
55
56
    /**
57
     * @param bool $landscape
58
     */
59
    public function setLandscape(bool $landscape): void
60
    {
61
        $this->landscape = $landscape;
62
    }
63
}
64