ContainsStrictRule::validate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
crap 3.0416
rs 10
1
<?php
2
3
/**
4
 * Bluz Framework Component
5
 *
6
 * @copyright Bluz PHP Team
7
 * @link      https://github.com/bluzphp/framework
8
 */
9
10
declare(strict_types=1);
11
12
namespace Bluz\Validator\Rule;
13
14
/**
15
 * Check for contains
16
 *
17
 * @package Bluz\Validator\Rule
18
 */
19
class ContainsStrictRule extends ContainsRule
20
{
21
    /**
22
     * Check input data
23
     *
24
     * @param  string|array $input
25
     *
26
     * @return bool
27
     */
28 6
    public function validate($input): bool
29
    {
30
        // for array
31 6
        if (is_array($input)) {
32 4
            return in_array($this->containsValue, $input, true);
33
        }
34
        // for string
35 2
        if (is_string($input)) {
0 ignored issues
show
introduced by
The condition is_string($input) is always true.
Loading history...
36 2
            return false !== mb_strpos($input, $this->containsValue, 0, mb_detect_encoding($input));
37
        }
38
        return false;
39
    }
40
}
41