CreateTokenCollection::getColumnList()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 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