ContainsDecimalValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

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