Completed
Push — master ( 328402...1cd18c )
by Julien
587:13 queued 584:54
created

ReverseProxyNewVirtualHostPayload::getService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\Aent\Payload\ReverseProxy;
4
5
use TheAentMachine\Aent\Payload\JsonPayloadInterface;
6
use TheAentMachine\Service\Exception\ServiceException;
7
use TheAentMachine\Service\Service;
8
9
final class ReverseProxyNewVirtualHostPayload implements JsonPayloadInterface
10
{
11
    /** @var string */
12
    private $baseVirtualHost;
13
14
    /** @var Service */
15
    private $service;
16
17
    /**
18
     * ReverseProxyNewVirtualHostPayload constructor.
19
     * @param string $baseVirtualHost
20
     * @param Service $service
21
     */
22
    public function __construct(string $baseVirtualHost, Service $service)
23
    {
24
        $this->baseVirtualHost = $baseVirtualHost;
25
        $this->service = $service;
26
    }
27
28
    /**
29
     * @return mixed[]
30
     * @throws ServiceException
31
     */
32
    public function toArray(): array
33
    {
34
        return [
35
            'BASE_VIRTUAL_HOST' => $this->baseVirtualHost,
36
            'SERVICE' => $this->service->jsonSerialize(),
37
        ];
38
    }
39
40
    /**
41
     * @param mixed[] $assoc
42
     * @return self
43
     * @throws ServiceException
44
     */
45
    public static function fromArray(array $assoc): self
46
    {
47
        return new self($assoc['BASE_VIRTUAL_HOST'], Service::parsePayload($assoc['SERVICE']));
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getBaseVirtualHost(): string
54
    {
55
        return $this->baseVirtualHost;
56
    }
57
58
    /**
59
     * @return Service
60
     */
61
    public function getService(): Service
62
    {
63
        return $this->service;
64
    }
65
}
66