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

RegexpValidation::run()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
ccs 6
cts 7
cp 0.8571
rs 9.4285
cc 2
eloc 7
nc 1
nop 2
crap 2.0116
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
}