Completed
Push — 2.x ( 6c47ee...c394f3 )
by Aleksei
24s queued 15s
created

CompileJsonLength::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 6
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\Injection;
13
14
use Cycle\Database\Injection\JsonExpression;
15
16
class CompileJsonLength extends JsonExpression
17
{
18
    /**
19
     * @param non-empty-string $statement
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...
20
     * @param int<0, max> $length
21
     * @param non-empty-string $operator
22
     */
23
    public function __construct(
24
        string $statement,
25
        int $length,
26
        protected string $operator
27
    ) {
28
        parent::__construct($statement, $length);
29
    }
30
31
    protected function compile(string $statement): string
32
    {
33
        return \sprintf(
34
            'json_array_length(%s%s) %s ?',
35
            $this->getField($statement),
36
            $this->getPath($statement),
37
            $this->operator
38
        );
39
    }
40
}
41