ASTFunctionCall   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 65
c 0
b 0
f 0
wmc 7
lcom 0
cbo 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createFromExpression() 0 13 2
A getArguments() 0 4 1
A setArguments() 0 4 1
A getFunctionName() 0 4 1
A setFunctionName() 0 4 1
1
<?php
2
3
namespace Netdudes\DataSourceryBundle\UQL\AST;
4
5
use Netdudes\DataSourceryBundle\UQL\Exception\UQLInterpreterException;
6
7
class ASTFunctionCall
8
{
9
    private $functionName;
10
11
    /**
12
     * @var array
13
     */
14
    private $arguments;
15
16
    /**
17
     * @param       $functionName
18
     * @param array $arguments
19
     */
20
    public function __construct($functionName, array $arguments)
21
    {
22
        $this->functionName = $functionName;
23
        $this->arguments = $arguments;
24
    }
25
26
    public static function createFromExpression($expressionString)
27
    {
28
        $matches = [];
29
        $isFunctionExpression = preg_match("/^([a-zA-Z0-9]+)\(([^\(\)]*)\)/", $expressionString, $matches);
30
        if (!$isFunctionExpression) {
31
            throw new UQLInterpreterException("Unexpected malformated function when trying to extract the parameters.");
32
        }
33
34
        $functionName = $matches[1];
35
        $arguments = array_filter(array_map('trim', explode(',', $matches[2])));
36
37
        return new self($functionName, $arguments);
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function getArguments()
44
    {
45
        return $this->arguments;
46
    }
47
48
    /**
49
     * @param array $arguments
50
     */
51
    public function setArguments($arguments)
52
    {
53
        $this->arguments = $arguments;
54
    }
55
56
    /**
57
     * @return mixed
58
     */
59
    public function getFunctionName()
60
    {
61
        return $this->functionName;
62
    }
63
64
    /**
65
     * @param mixed $functionName
66
     */
67
    public function setFunctionName($functionName)
68
    {
69
        $this->functionName = $functionName;
70
    }
71
}
72