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

serializeMultiChildProperties()   A

Complexity

Conditions 6
Paths 8

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 7.3329

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 6
eloc 8
nc 8
nop 0
dl 0
loc 17
ccs 6
cts 9
cp 0.6667
crap 7.3329
rs 9.2222
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\Traits;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\Component\APLBaseComponent;
8
9
trait MultiChildComponentTrait
10
{
11
    public ?array $data = null;
12
    /** @var APLBaseComponent|APLBaseComponent[]|null */
13
    public $item = null;
14
    /** @var APLBaseComponent[]|null */
15
    public ?array $items = null;
16
17 24
    protected function serializeMultiChildProperties(): array
18
    {
19 24
        $data = [];
20
21 24
        if ($this->data !== null && !empty($this->data)) {
22
            $data['data'] = $this->data;
23
        }
24
25 24
        if ($this->item !== null) {
26
            $data['item'] = $this->item;
27
        }
28
29 24
        if ($this->items !== null && !empty($this->items)) {
30
            $data['items'] = $this->items;
31
        }
32
33 24
        return $data;
34
    }
35
}
36