ContainsDecimalValidator::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 9.4285
1
<?php
2
3
/**
4
 * @author Rafał Muszyński <[email protected]>
5
 * @copyright 2013 Sourcefabric o.p.s.
6
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
7
 */
8
namespace Newscoop\PaywallBundle\Validator\Constraints;
9
10
use Symfony\Component\Validator\Constraint;
11
use Symfony\Component\Validator\ConstraintValidator;
12
13
class ContainsDecimalValidator extends ConstraintValidator
14
{
15
    /**
16
     * Add violations to the validator's context property.
17
     *
18
     * @param string                                 $value
19
     * @param Symfony\Component\Validator\Constraint $constraint
20
     */
21
    public function validate($value, Constraint $constraint)
22
    {
23
        if (!is_numeric($value)) {
24
            $this->context->addViolation($constraint->message);
25
        }
26
    }
27
}
28