Completed
Push — bridge-refactor ( 54fa11 )
by Sullivan
05:53
created

IsoCodesGenericValidator::validate()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 11
rs 9.4285
1
<?php
2
3
namespace SLLH\IsoCodesValidator\Constraints;
4
5
use SLLH\IsoCodesValidator\AbstractIsoCodesConstraintValidator;
6
use Symfony\Component\Validator\Constraint;
7
8
/**
9
 * @author Sullivan Senechal <[email protected]>
10
 */
11
class IsoCodesGenericValidator extends AbstractIsoCodesConstraintValidator
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function validate($value, Constraint $constraint)
17
    {
18
        parent::validate($value, $constraint);
19
20
        $constraintClass = str_replace('SLLH\\IsoCodesValidator\\Constraints\\', '', get_class($constraint));
21
        $isoCodesClass = 'IsoCodes\\'.$constraintClass;
22
23
        if ($value && !$isoCodesClass::validate($value)) {
24
            $this->createViolation($constraint->message);
25
        }
26
    }
27
}
28