Test Failed
Push — master ( 91a335...e8c3d6 )
by Dmitriy
10:59
created

CallableExpressionProvider::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace App;
5
6
use Opis\Closure\SerializableClosure;
7
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
8
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
9
use Yiisoft\Injector\Injector;
10
11
class CallableExpressionProvider implements ExpressionFunctionProviderInterface
12
{
13
    public function getFunctions()
14
    {
15
        return [
16
            new ExpressionFunction('closure',
17
                function ($arg) {
18
                    return $arg;
19
                }, function (array $variables, $value) {
20
                    $c = unserialize($value);
21
                    $injector = new Injector($variables['container']);
22
                    return $injector->invoke($c);
23
                }),
24
        ];
25
    }
26
}
27