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

MultiChildComponentTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 25
ccs 6
cts 9
cp 0.6667
rs 10
c 1
b 0
f 1
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A serializeMultiChildProperties() 0 17 6
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