Passed
Push — feature/initial-implementation ( 3b7c72...40c5a6 )
by Fike
01:49
created

ExistingParameterValidator::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Mapping\Validation\Constraint;
6
7
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\Infrastructure\Registry;
8
use Symfony\Component\Validator\Constraint;
9
use Symfony\Component\Validator\ConstraintValidator;
10
11
class ExistingParameterValidator extends ConstraintValidator
12
{
13
    /**
14
     * @inheritDoc
15
     * @param ExistingParameter $constraint
16
     */
17 View Code Duplication
    public function validate($value, Constraint $constraint)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        if (!Registry::getInstance()->find($value)) {
20
            $this
21
                ->context
22
                ->buildViolation($constraint->message)
23
                ->setParameter('{{ name }}', $value)
24
                ->addViolation();
25
        }
26
    }
27
}
28