Completed
Push — master ( 6f2bb4...6400d0 )
by Anton
11s
created

ContainsStrictRule::validate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

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