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

UqlFunctionCaller   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A callFunction() 0 9 2
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