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

UqlFunctionCaller::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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