Passed
Pull Request — master (#97)
by Maximilian
03:52
created

Environment::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
nc 1
nop 3
dl 0
loc 5
ccs 1
cts 1
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
class Environment implements \JsonSerializable
8
{
9
    /**
10
     * @param string|null $lang Language setting
11
     * @param LayoutDirection|null $layoutDirection Layout direction setting
12
     * @param string[]|null $parameters Array of parameter strings
13
     */
14 12
    public function __construct(
15
        public ?string $lang = null,
16
        public ?LayoutDirection $layoutDirection = null,
17
        public ?array $parameters = null,
18
    ) {
19 12
    }
20
21 7
    public function jsonSerialize(): array
22
    {
23 7
        $data = [];
24 7
        if ($this->lang !== null) {
25 3
            $data['lang'] = $this->lang;
26
        }
27 7
        if ($this->layoutDirection !== null) {
28 3
            $data['layoutDirection'] = $this->layoutDirection->value;
29
        }
30 7
        if ($this->parameters !== null && count($this->parameters) > 0) {
31 4
            $data['parameters'] = $this->parameters;
32
        }
33
34 7
        return $data;
35
    }
36
}
37