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

Collection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 20
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 __unset() 0 6 2
1
<?php
2
3
namespace Softonic\GraphQL\DataObjects\Mutation;
4
5
class Collection extends FilteredCollection
6
{
7 16
    public function add(array $itemData): void
8
    {
9 16
        if (!empty($this->arguments[0]) && $this->arguments[0] instanceof Collection) {
10 8
            foreach ($this->arguments as $argument) {
11 8
                $argument->add($itemData);
12
            }
13
        } else {
14 16
            $this->arguments[] = new Item($itemData, $this->config, true);
15
        }
16 16
    }
17
18 4
    public function __unset($key): void
19
    {
20 4
        foreach ($this->arguments as $argument) {
21 4
            unset($argument->{$key});
22
        }
23 4
    }
24
}
25