Completed
Pull Request — master (#45)
by Jose Manuel
02:24
created

Collection::jsonSerialize()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 7
cp 0
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 12
1
<?php
2
3
namespace Softonic\GraphQL\DataObjects\Query;
4
5
use Softonic\GraphQL\DataObjects\AbstractCollection;
6
7
class Collection extends AbstractCollection implements QueryObject
8
{
9
    public function jsonSerialize(): array
10
    {
11
        if (!$this->hasChildren()) {
12
            return [];
13
        }
14
15
        $items = [];
16
        foreach ($this->arguments as $item) {
17
            $items[] = $item->jsonSerialize();
18
        }
19
20
        return $items;
21
    }
22
23 12
    protected function buildFilteredCollection($items)
24
    {
25 12
        return new Collection($items);
26
    }
27
28 12
    protected function buildSubCollection(array $items, string $key)
29
    {
30 12
        return new Collection($items);
31
    }
32
}
33