ColumnExpression::getExpressions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @category    Brownie/BpmOnline
4
 * @author      Brownie <[email protected]>
5
 * @license     https://opensource.org/licenses/MIT
6
 */
7
8
namespace Brownie\BpmOnline\DataService\Column;
9
10
/**
11
 * An expression defining a column type.
12
 */
13
class ColumnExpression implements Column
14
{
15
16
    /**
17
     * Collection of expressions.
18
     *
19
     * @var Expression[]
20
     */
21
    private $expressions = [];
22
23
    /**
24
     * Sets the input values.
25
     *
26
     * @param Expression|null   $_      Collection of expressions.
27
     */
28 1
    public function __construct(Expression $_ = null)
29
    {
30 1
        $this->setExpressions(func_get_args());
31 1
    }
32
33
    /**
34
     * Sets collection of expressions.
35
     * Returns the current object.
36
     *
37
     * @param array     $expressions    Collection of expressions.
38
     *
39
     * @return self
40
     */
41 1
    private function setExpressions(array $expressions)
42
    {
43 1
        $this->expressions = $expressions;
44 1
        return $this;
45
    }
46
47
    /**
48
     * Gets collection of expressions.
49
     *
50
     * @return Expression[]
51
     */
52 1
    private function getExpressions()
53
    {
54 1
        return $this->expressions;
55
    }
56
57
    /**
58
     * Returns data as an associative array.
59
     *
60
     * @return array
61
     */
62 1
    public function toArray()
63
    {
64 1
        $expressions = [];
65 1
        foreach ($this->getExpressions() as $expression) {
66 1
            $expressions[$expression->getKeyName()] = $expression->getValue();
67
        }
68 1
        return $expressions;
69
    }
70
}
71