Completed
Pull Request — master (#15)
by
unknown
02:47
created

UqlFunctionCaller::callFunction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 3
1
<?php
2
3
namespace Netdudes\DataSourceryBundle\Extension;
4
5
use Netdudes\DataSourceryBundle\Extension\Exception\FunctionNotFoundException;
6
7
class UqlFunctionCaller
8
{
9
    /**
10
     * @var UqlExtensionContainer
11
     */
12
    private $uqlExtensionContainer;
13
14
    /**
15
     * @param UqlExtensionContainer $uqlExtensionContainer
16
     */
17
    public function __construct(UqlExtensionContainer $uqlExtensionContainer)
18
    {
19
        $this->uqlExtensionContainer = $uqlExtensionContainer;
20
    }
21
22
    /**
23
     * @param string  $name
24
     * @param array   $arguments
25
     * @param Context $context
26
     *
27
     * @return mixed
28
     * @throws Exception\FunctionNotFoundException
29
     */
30
    public function callFunction($name, $arguments, Context $context)
31
    {
32
        $functions = $this->uqlExtensionContainer->getFunctions();
33
        if (!isset($functions[$name])) {
34
            throw new FunctionNotFoundException("Could not find UQL function $name");
35
        }
36
37
        return $functions[$name]->call($arguments, $context);
38
    }
39
}
40