Test Failed
Push — master ( e4a428...eca95d )
by Ricardo
04:31
created

BlockStringTrait::foundInArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 4
c 1
b 0
f 1
nc 3
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace Validate\Traits;
4
5
/**
6
 * Undocumented trait
7
 */
8
trait BlockStringTrait
9
{
10
    /**
11
     * Found many strings inside multiples arrays
12
     *
13
     * @param string $blocks
14
     * @return bool
15
     */
16
    public static function foundInMultiplesArrays($blocks)
17
    {
18
        foreach ($blocks as $block) {
0 ignored issues
show
Bug introduced by
The expression $blocks of type string is not traversable.
Loading history...
19
            if (static::foundInArray($block[0], $block[1])) {
20
                return true;
21
            }
22
        }
23
        return false;
24
    }
25
26
    /**
27
     * Found string inside array
28
     *
29
     * @param string $field
30
     * @param array $array
31
     * @return bool
32
     */
33
    public static function foundInArray($field, $array)
34
    {
35
        foreach ($array as $notPermit) {
36
            if(strpos($field, $notPermit) !== false){
37
                return true;
38
            }
39
        }
40
        return false;
41
    }
42
}