Completed
Pull Request — master (#42)
by Jose Manuel
01:40
created

Collection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 10 4
A __get() 0 8 2
1
<?php
2
3
namespace Softonic\GraphQL\Mutation;
4
5
use Softonic\GraphQL\Exceptions\InaccessibleArgumentException;
6
7
class Collection extends FilteredCollection
8
{
9 40
    public function __get(string $key): Collection
10
    {
11 40
        if (empty($this->arguments)) {
12 2
            throw InaccessibleArgumentException::fromEmptyArguments($key);
13
        }
14
15 38
        return parent::__get($key);
16
    }
17
18 16
    public function add(array $itemData): void
19
    {
20 16
        if (!empty($this->arguments[0]) && $this->arguments[0] instanceof Collection) {
21 8
            foreach ($this->arguments as $argument) {
22 8
                $argument->add($itemData);
23
            }
24
        } else {
25 16
            $this->arguments[] = new Item($itemData, $this->config, true);
26
        }
27 16
    }
28
}
29