URLRequest::getPostURL()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TheCodingMachine\Gotenberg;
6
7
final class URLRequest extends ChromeRequest implements GotenbergRequestInterface
8
{
9
    private const REMOTE_URL = 'remoteURL';
10
11
    private const REMOTE_URL_BASE_HTTP_HEADER_KEY = 'Gotenberg-Remoteurl-';
12
13
    /** @var string */
14
    private $URL;
15
16
    public function __construct(string $URL)
17
    {
18
        parent::__construct();
19
        $this->URL = $URL;
20
    }
21
22
    public function getPostURL(): string
23
    {
24
        return '/convert/url';
25
    }
26
27
    /**
28
     * @return array<string,mixed>
29
     */
30
    public function getFormValues(): array
31
    {
32
        $values = parent::getFormValues();
33
        $values[self::REMOTE_URL] = $this->URL;
34
35
        return $values;
36
    }
37
38
    public function addRemoteURLHTTPHeader(string $key, string $value): void
39
    {
40
        $key = self::REMOTE_URL_BASE_HTTP_HEADER_KEY . $key;
41
        $this->customHTTPHeaders[$key] = $value;
42
    }
43
}
44