Completed
Push — phonenumber ( a83019...70d761 )
by Sullivan
02:26
created

PhoneNumberValidator::validate()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 3
eloc 4
nc 2
nop 2
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 View Code Duplication
class PhoneNumberValidator extends AbstractIsoCodesConstraintValidator
0 ignored issues
show
Duplication introduced by
This class 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...
12
{
13
    /**
14
     * @param mixed                  $value
15
     * @param PhoneNumber|Constraint $constraint
16
     */
17
    public function validate($value, Constraint $constraint)
18
    {
19
        parent::validate($value, $constraint);
20
21
        if ($value && !\IsoCodes\PhoneNumber::validate($value, $constraint->country)) {
22
            // TODO: Manage the "All country" option as for ZipCode.
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
23
            $this->createViolation($constraint->message);
24
        }
25
    }
26
}
27