Completed
Pull Request — master (#29)
by
unknown
06:10
created

Collection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 90%

Importance

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

2 Methods

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