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

CompileJsonLength   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A compile() 0 7 1
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\MySQL\Injection;
13
14
class CompileJsonLength extends MySQLJsonExpression
15
{
16
    /**
17
     * @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...
18
     * @param int<0, max> $length
19
     * @param non-empty-string $operator
20
     */
21
    public function __construct(
22
        string $statement,
23
        int $length,
24
        protected string $operator
25
    ) {
26
        parent::__construct($statement, $length);
27
    }
28
29
    protected function compile(string $statement): string
30
    {
31
        return \sprintf(
32
            'json_length(%s%s) %s ?',
33
            $this->getField($statement),
34
            $this->getPath($statement),
35
            $this->operator
36
        );
37
    }
38
}
39