Completed
Branch 2.0 (acba87)
by Vermeulen
02:20
created

ColumnValueList   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 13 3
A __invoke() 0 4 2
1
<?php
2
3
namespace BfwSql\Queries\Parts;
4
5
class ColumnValueList extends ColumnList
6
{
7
    /**
8
     * {@inheritdoc}
9
     * 
10
     * @param array $columns The list of columns to declare
11
     *  The key into the array is the name of the column.
12
     *  The value is the column value.
13
     */
14
    public function __invoke(array $columns)
15
    {
16
        foreach ($columns as $name => $value) {
17
            $this->list[] = new Column($this->table, $name, null, $value);
18
        }
19
    }
20
    
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function generate(): string
25
    {
26
        $sqlPart = '';
27
        
28
        foreach ($this->list as $index => $column) {
29
            if ($index > 0) {
30
                $sqlPart .= $this->separator;
31
            }
32
            
33
            $sqlPart .= $column->obtainName().'='.$column->obtainValue();
34
        }
35
        
36
        return $sqlPart;
37
    }
38
}
39