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

Collection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 36.36%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 26
ccs 4
cts 11
cp 0.3636
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 13 3
A buildFilteredCollection() 0 4 1
A buildSubCollection() 0 4 1
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