ContainsStrictRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 20
ccs 5
cts 6
cp 0.8333
rs 10
wmc 3

1 Method

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