Completed
Push — master ( 949a11...75d1c6 )
by David
03:05 queued 10s
created

SharedEnvVariable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 7 1
A getContainerId() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace TheAentMachine\Service\Environment;
4
5
class SharedEnvVariable extends EnvVariable
6
{
7
    /**
8
     * @var null|string
9
     */
10
    private $containerId;
11
12
    public function __construct(string $value, string $type, ?string $comment, ?string $containerId)
13
    {
14
        parent::__construct($value, $type, $comment);
15
        $this->containerId = $containerId;
16
    }
17
18
    /**
19
     * @return null|string
20
     */
21
    public function getContainerId(): ?string
22
    {
23
        return $this->containerId;
24
    }
25
26
    /**
27
     * Specify data which should be serialized to JSON
28
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
29
     * @return array data which can be serialized by <b>json_encode</b>,
30
     * which is a value of any type other than a resource.
31
     * @since 5.4.0
32
     */
33
    public function jsonSerialize(): array
34
    {
35
        return array_filter([
36
            'value' => $this->getValue(),
37
            'type' => $this->getType(),
38
            'comment' => $this->getComment(),
39
            'containerId' => $this->containerId
40
        ]);
41
    }
42
}
43