CreateTokenCollection   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 48
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

4 Methods

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