Passed
Push — master ( a57761...826c30 )
by test
04:09
created

Clause   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 46
ccs 11
cts 11
cp 1
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A intercepted() 0 3 1
A interceptWhereClause() 0 10 4
A where() 0 5 1
1
<?php
2
3
namespace EasyIM\Kernel\Clauses;
4
5
/**
6
 * Class Clause.
7
 */
8
class Clause
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $clauses = [
14
        'where' => [],
15
    ];
16
17
    /**
18
     * @param mixed ...$args
19
     *
20
     * @return $this
21
     */
22 2
    public function where(...$args)
23
    {
24 2
        array_push($this->clauses['where'], $args);
25
26 2
        return $this;
27
    }
28
29
    /**
30
     * @param mixed $payload
31
     *
32
     * @return bool
33
     */
34 8
    public function intercepted($payload)
35
    {
36 8
        return (bool) $this->interceptWhereClause($payload);
37
    }
38
39
    /**
40
     * @param mixed $payload
41
     *
42
     * @return bool
43
     */
44 8
    protected function interceptWhereClause($payload)
45
    {
46 8
        foreach ($this->clauses['where'] as $item) {
47 2
            list($key, $value) = $item;
48 2
            if (isset($payload[$key]) && $payload[$key] !== $value) {
49 2
                return true;
50
            }
51
        }
52
53 8
        return false;
54
    }
55
}
56