Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — master ( 83db66...8ac73c )
by Jérémiah
21:08
created

ExpressionValidator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Validator\Constraints;
6
7
use Overblog\GraphQLBundle\Validator\ValidationNode;
8
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
9
use Symfony\Component\Validator\Constraint;
10
use Symfony\Component\Validator\Constraints\Expression;
11
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
12
13
class ExpressionValidator extends \Symfony\Component\Validator\Constraints\ExpressionValidator
14
{
15
    private $expressionLanguage;
16
17 7
    public function __construct(ExpressionLanguage $expressionLanguage)
18
    {
19 7
        $this->expressionLanguage = $expressionLanguage;
20 7
        parent::__construct(null, $expressionLanguage);
21 7
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 7
    public function validate($value, Constraint $constraint): void
27
    {
28 7
        if (!$constraint instanceof Expression) {
29
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Expression');
30
        }
31
32 7
        $variables = $constraint->values;
33 7
        $variables['value'] = $value;
34
35 7
        $object = $this->context->getObject();
36
37 7
        $variables['this'] = $object;
38
39 7
        if ($object instanceof ValidationNode) {
40 7
            $variables['parentValue'] = $object->getResolverArg('value');
41 7
            $variables['context'] = $object->getResolverArg('context');
42 7
            $variables['args'] = $object->getResolverArg('args');
43 7
            $variables['info'] = $object->getResolverArg('info');
44
        }
45
46 7
        if (!$this->expressionLanguage->evaluate($constraint->expression, $variables)) {
47 3
            $this->context->buildViolation($constraint->message)
48 3
                ->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING))
49 3
                ->setCode(Expression::EXPRESSION_FAILED_ERROR)
50 3
                ->addViolation();
51
        }
52 7
    }
53
}
54