Passed
Push — master ( 77e09c...64b758 )
by Rafael
07:59
created

FieldExpressionResolver::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 0
cts 13
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 6
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Resolver;
12
13
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
14
15
/**
16
 * FieldExpressionResolver
17
 */
18
class FieldExpressionResolver extends AbstractResolver
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function __invoke($root)
24
    {
25
        $language = new ExpressionLanguage();
26
        if ($this->getContext()->getDefinition()->hasMeta('expression')) {
27
            $expression = $this->getContext()->getDefinition()->getMeta('expression');
28
29
            return $language->evaluate(
30
                $expression,
31
                [
32
                    'this' => $root,
33
                ]
34
            );
35
        }
36
37
        return null;
38
    }
39
}
40