Completed
Push — master ( c817f5...bf255d )
by Beniamin
03:22
created

FunctionExpression::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Phuria\QueryBuilder\Expression;
4
5
/**
6
 * @author Beniamin Jonatan Šimko <[email protected]>
7
 */
8
class FunctionExpression implements ExpressionInterface
9
{
10
    const FUNC_ASCI = 'ASCI';
11
    const FUNC_BIN = 'BIN';
12
    const FUNC_BIT_LENGTH = 'BIT_LENGTH';
13
    const FUNC_CHAR = 'CHAR';
14
    const FUNC_COALESCE = 'COALESCE';
15
    const FUNC_CONCAT = 'CONCAT';
16
    const FUNC_CONCAT_WS = 'CONCAT_WS';
17
    const FUNC_ELT = 'ELT';
18
    const FUNC_EXPORT_SET = 'EXPORT_SET';
19
    const FUNC_FIELD = 'FIELD';
20
    const FUNC_MAX = 'MAX';
21
    const FUNC_SUM = 'SUM';
22
    const FUNC_YEAR = 'YEAR';
23
24
    /**
25
     * @var string $functionName
26
     */
27
    private $functionName;
28
29
    /**
30
     * @var ExpressionInterface $args
31
     */
32
    private $arguments;
33
34
    /**
35
     * @param $functionName
36
     * @param $arguments
37
     */
38 7
    public function __construct($functionName, ExpressionInterface $arguments)
39
    {
40 7
        $this->functionName = $functionName;
41 7
        $this->arguments = $arguments;
42 7
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47 7
    public function compile()
48
    {
49 7
        return $this->functionName . '(' . $this->arguments->compile() . ')';
50
    }
51
}