Passed
Pull Request — master (#97)
by Maximilian
04:02
created

PseudoLocalization::jsonSerialize()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 6
nc 4
nop 0
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 3
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 PseudoLocalization implements \JsonSerializable
8
{
9 13
    public function __construct(
10
        public bool $enabled = false,
11
        public int $expansionPercentage = 30,
12
    ) {
13 13
    }
14
15 9
    public function jsonSerialize(): array
16
    {
17 9
        $data = [];
18
19 9
        if ($this->enabled) {
20 5
            $data['enabled'] = $this->enabled;
21
        }
22 9
        if ($this->expansionPercentage !== 30) {
23 5
            $data['expansionPercentage'] = $this->expansionPercentage;
24
        }
25
26 9
        return $data;
27
    }
28
}
29