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

FieldExpressionResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 20
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 2
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