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

Collection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
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
class Collection extends FilteredCollection
6
{
7 16
    public function __get(string $key)
8
    {
9 16
        if (empty($this->arguments)) {
10
            throw new \Exception('You cannot access a non existing collection');
11
        }
12
13 16
        return parent::__get($key);
14
    }
15
16 8
    public function add(array $itemData)
17
    {
18 8
        if (!empty($this->arguments[0]) && $this->arguments[0] instanceof Collection) {
19 4
            foreach ($this->arguments as $argument) {
20 4
                $argument->add($itemData);
21
            }
22
        } else {
23 8
            $this->arguments[] = new Item($itemData, $this->config, true);
24
        }
25 8
    }
26
}
27