Completed
Push — master ( 37f724...36a3c8 )
by Julien
03:13
created

KubernetesReplyDeployJobPayload::fromArray()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\Aent\Payload\CI;
4
5
use TheAentMachine\Aent\Payload\JsonPayloadInterface;
6
7
final class KubernetesReplyDeployJobPayload implements JsonPayloadInterface
8
{
9
    /** @var bool */
10
    private $withManyEnvironments;
11
12
    /**
13
     * KubernetesReplyDeployJobPayload constructor.
14
     * @param bool $withManyEnvironments
15
     */
16
    public function __construct(bool $withManyEnvironments)
17
    {
18
        $this->withManyEnvironments = $withManyEnvironments;
19
    }
20
21
    /**
22
     * @return array<string,string>
23
     */
24
    public function toArray(): array
25
    {
26
        return [
27
            'WITH_MANY_ENVIRONMENTS' => $this->withManyEnvironments ? '1' : '0',
28
        ];
29
    }
30
31
    /**
32
     * @param array<string,string> $assoc
33
     * @return self
34
     */
35
    public static function fromArray(array $assoc): self
36
    {
37
        return new self($assoc['WITH_MANY_ENVIRONMENTS'] === '1');
38
    }
39
40
    /**
41
     * @return bool
42
     */
43
    public function isWithManyEnvironments(): bool
44
    {
45
        return $this->withManyEnvironments;
46
    }
47
}
48