OfficeRequest::setPageRanges()   A
last analyzed

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
final class OfficeRequest extends Request implements GotenbergRequestInterface
8
{
9
    private const LANDSCAPE = 'landscape';
10
    private const PAGE_RANGES = 'pageRanges';
11
12
    /** @var Document[] */
13
    private $files;
14
15
    /** @var bool */
16
    private $landscape;
17
18
    /** @var string|null */
19
    private $pageRanges;
20
21
    /**
22
     * @param Document[] $files
23
     */
24
    public function __construct(array $files)
25
    {
26
        parent::__construct();
27
        $this->files = $files;
28
    }
29
30
    public function getPostURL(): string
31
    {
32
        return '/convert/office';
33
    }
34
35
    /**
36
     * @return array<string,mixed>
37
     */
38
    public function getFormValues(): array
39
    {
40
        $values = parent::getFormValues();
41
        if ($this->pageRanges !== null) {
42
            $values[self::PAGE_RANGES] = $this->pageRanges;
43
        }
44
        $values[self::LANDSCAPE] = $this->landscape;
45
46
        return $values;
47
    }
48
49
    /**
50
     * @return array<string,Document>
51
     */
52
    public function getFormFiles(): array
53
    {
54
        $files = [];
55
        foreach ($this->files as $file) {
56
            $files[$file->getFileName()] = $file;
57
        }
58
59
        return $files;
60
    }
61
62
    public function setLandscape(bool $landscape): void
63
    {
64
        $this->landscape = $landscape;
65
    }
66
67
    public function setPageRanges(string $pageRanges): void
68
    {
69
        $this->pageRanges = $pageRanges;
70
    }
71
}
72