GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 698fd2...95f32c )
by Christian
10:54 queued 08:21
created

Builder::whereEnigma()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Omatech\Enigma\Database\Query;
4
5
use Omatech\Enigma\CipherSweet\Index;
6
use Omatech\Enigma\Enigma;
7
8
class Builder extends \Illuminate\Database\Query\Builder
9
{
10
    /**
11
     * @param string $column
12
     * @param string $value
13
     * @param Index $index
14
     * @param string $boolean
15
     * @return $this
16
     * @throws \ParagonIE\CipherSweet\Exception\BlindIndexNameCollisionException
17
     * @throws \ParagonIE\CipherSweet\Exception\CryptoOperationException
18
     */
19 8
    public function whereEnigma(string $column, string $value, Index $index, string $boolean = 'and'): self
20
    {
21 8
        $this->findByHash($column, $value, $index, $boolean);
22
23 8
        return $this;
24
    }
25
26
    /**
27
     * @param string $column
28
     * @param string $value
29
     * @param Index $index
30
     * @return $this
31
     * @throws \ParagonIE\CipherSweet\Exception\BlindIndexNameCollisionException
32
     * @throws \ParagonIE\CipherSweet\Exception\CryptoOperationException
33
     */
34 4
    public function orWhereEnigma(string $column, string $value, Index $index): self
35
    {
36 4
        return $this->whereEnigma($column, $value, $index, 'or');
37
    }
38
39
    /**
40
     * @param string $column
41
     * @param string $value
42
     * @param Index $index
43
     * @param string $boolean
44
     * @return Builder
45
     * @throws \ParagonIE\CipherSweet\Exception\BlindIndexNameCollisionException
46
     * @throws \ParagonIE\CipherSweet\Exception\CryptoOperationException
47
     */
48 8
    private function findByHash(string $column, string $value, Index $index, string $boolean): self
49
    {
50 8
        $ids = (new Enigma)->search($this->from, $column, $value, $index);
51
52 8
        if ($ids !== null) {
0 ignored issues
show
introduced by
The condition $ids !== null is always true.
Loading history...
53
            $closure = static function (self $query) use ($ids) {
54 8
                $query->whereRaw("id IN ($ids)");
55 8
            };
56
57 8
            $boolean === 'and'
58 8
            ? $this->where($closure)
59 4
            : $this->orWhere($closure);
60
        }
61
62 8
        return $this;
63
    }
64
}
65