Completed
Push — master ( 39ca89...64a0db )
by James Ekow Abaka
03:49
created

RegexpValidation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 13
c 0
b 0
f 0
ccs 6
cts 7
cp 0.8571
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 2
1
<?php
2
3
namespace ntentan\utils\validator\validations;
4
use ntentan\utils\validator\Validation;
5
6
class RegexpValidation extends Validation
7
{
8 1
    public function run($field, $data)
9
    {
10 1
        $value = $this->getFieldValue($field, $data);
11 1
        return $this->evaluateResult(
12
            $field,
13 1
            preg_match_all(is_string($field['options']) ? 
0 ignored issues
show
Documentation introduced by
preg_match_all(is_string...['options'][0], $value) is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
14 1
                $field['options'] : $field['options'][0], $value), 
15 1
            "The format of your input is invalid"
16
        );       
17
    }
18
}