UpdateTokenCollection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A toString() 0 10 2
A getBindingsList() 0 10 2
1
<?php
2
3
namespace Hgraca\MicroDbal\Crud\QueryBuilder\Sql;
4
5
final class UpdateTokenCollection
6
{
7
    /** @var UpdateToken[] */
8
    private $collection;
9
10
    /** @var int */
11
    private $bindingCounter = 0;
12
13 4
    public function __construct(array $dataSet)
14
    {
15 4
        foreach ($dataSet as $column => $value) {
16 4
            $this->collection[] = new UpdateToken($column, $value, $this->bindingCounter++);
17
        };
18 4
    }
19
20 3
    public function toString(): string
21
    {
22 3
        $updateStringTokens = [];
23
24 3
        foreach ($this->collection as $updateToken) {
25 3
            $updateStringTokens[] = $updateToken->toString();
26
        }
27
28 3
        return implode(', ', $updateStringTokens);
29
    }
30
31 3
    public function getBindingsList(): array
32
    {
33 3
        $bindingsList = [];
34
35 3
        foreach ($this->collection as $updateToken) {
36 3
            $bindingsList[] = $updateToken->getBinding();
37
        }
38
39 3
        return array_merge(...$bindingsList);
40
    }
41
}
42