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

IsoCodesGenericValidator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 11 3
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