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

ContainsStrictRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

1 Method

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