Passed
Pull Request — 2.x (#135)
by Maxim
20:06
created

WhereJsonTrait::andWhereJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 10
rs 10
1
<?php
2
3
/**
4
 * This file is part of Cycle ORM package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Database\Driver\SQLite\Query\Traits;
13
14
use Cycle\Database\Driver\SQLite\Injection\CompileJson;
15
use Cycle\Database\Exception\DriverException;
16
17
/**
18
 * @internal
19
 */
20
trait WhereJsonTrait
21
{
22
    /**
23
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
24
     *
25
     * @return $this|self
26
     */
27
    public function whereJson(string $column, mixed $value): self
28
    {
29
        $this->registerToken(
0 ignored issues
show
Bug introduced by
It seems like registerToken() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $this->/** @scrutinizer ignore-call */ 
30
               registerToken(
Loading history...
30
            'AND',
31
            [new CompileJson($column), $value],
32
            $this->whereTokens,
33
            $this->whereWrapper()
0 ignored issues
show
Bug introduced by
It seems like whereWrapper() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
            $this->/** @scrutinizer ignore-call */ 
34
                   whereWrapper()
Loading history...
34
        );
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
41
     *
42
     * @return $this|self
43
     */
44
    public function andWhereJson(string $column, mixed $value): self
45
    {
46
        $this->registerToken(
47
            'AND',
48
            [new CompileJson($column), $value],
49
            $this->whereTokens,
50
            $this->whereWrapper()
51
        );
52
53
        return $this;
54
    }
55
56
    /**
57
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
58
     *
59
     * @return $this|self
60
     */
61
    public function orWhereJson(string $column, mixed $value): self
62
    {
63
        $this->registerToken(
64
            'OR',
65
            [new CompileJson($column), $value],
66
            $this->whereTokens,
67
            $this->whereWrapper()
68
        );
69
70
        return $this;
71
    }
72
73
    /**
74
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
75
     *
76
     * @return $this|self
77
     */
78
    public function whereJsonContains(string $column, mixed $value): self
0 ignored issues
show
Unused Code introduced by
The parameter $column is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

78
    public function whereJsonContains(/** @scrutinizer ignore-unused */ string $column, mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

78
    public function whereJsonContains(string $column, /** @scrutinizer ignore-unused */ mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
79
    {
80
        throw new DriverException('This database engine does not support JSON contains operations.');
81
    }
82
83
    /**
84
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
85
     *
86
     * @return $this|self
87
     */
88
    public function andWhereJsonContains(string $column, mixed $value): self
0 ignored issues
show
Unused Code introduced by
The parameter $column is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

88
    public function andWhereJsonContains(/** @scrutinizer ignore-unused */ string $column, mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

88
    public function andWhereJsonContains(string $column, /** @scrutinizer ignore-unused */ mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
89
    {
90
        throw new DriverException('This database engine does not support JSON contains operations.');
91
    }
92
93
    /**
94
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
95
     *
96
     * @return $this|self
97
     */
98
    public function orWhereJsonContains(string $column, mixed $value): self
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

98
    public function orWhereJsonContains(string $column, /** @scrutinizer ignore-unused */ mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $column is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

98
    public function orWhereJsonContains(/** @scrutinizer ignore-unused */ string $column, mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
99
    {
100
        throw new DriverException('This database engine does not support JSON contains operations.');
101
    }
102
103
    /**
104
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
105
     *
106
     * @return $this|self
107
     */
108
    public function whereJsonDoesntContain(string $column, mixed $value): self
0 ignored issues
show
Unused Code introduced by
The parameter $column is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

108
    public function whereJsonDoesntContain(/** @scrutinizer ignore-unused */ string $column, mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

108
    public function whereJsonDoesntContain(string $column, /** @scrutinizer ignore-unused */ mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
109
    {
110
        throw new DriverException('This database engine does not support JSON contains operations.');
111
    }
112
113
    /**
114
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
115
     *
116
     * @return $this|self
117
     */
118
    public function andWhereJsonDoesntContain(string $column, mixed $value): self
0 ignored issues
show
Unused Code introduced by
The parameter $column is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

118
    public function andWhereJsonDoesntContain(/** @scrutinizer ignore-unused */ string $column, mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

118
    public function andWhereJsonDoesntContain(string $column, /** @scrutinizer ignore-unused */ mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
119
    {
120
        throw new DriverException('This database engine does not support JSON contains operations.');
121
    }
122
123
    /**
124
     * @param non-empty-string $column
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
125
     *
126
     * @return $this|self
127
     */
128
    public function orWhereJsonDoesntContain(string $column, mixed $value): self
0 ignored issues
show
Unused Code introduced by
The parameter $column is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

128
    public function orWhereJsonDoesntContain(/** @scrutinizer ignore-unused */ string $column, mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

128
    public function orWhereJsonDoesntContain(string $column, /** @scrutinizer ignore-unused */ mixed $value): self

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
129
    {
130
        throw new DriverException('This database engine does not support JSON contains operations.');
131
    }
132
}
133