Passed
Pull Request — 2.x (#135)
by Aleksei
18:00
created

SQLServerJsonExpression::getPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
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\SQLServer\Injection;
13
14
use Cycle\Database\Injection\JsonExpression;
15
16
abstract class SQLServerJsonExpression extends JsonExpression
17
{
18
    /**
19
     * @return non-empty-string
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
     */
21
    protected function getQuotes(): string
22
    {
23
        return '[]';
24
    }
25
26
    /**
27
     * @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...
28
     *
29
     * @return non-empty-string
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...
30
     */
31
    protected function getField(string $statement): string
32
    {
33
        $parts = \explode('->', $statement, 2);
34
35
        return $this->quoter->quote($parts[0]);
36
    }
37
38
    /**
39
     * @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...
40
     *
41
     * @return non-empty-string
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...
42
     */
43
    protected function getPath(string $statement): string
44
    {
45
        $parts = \explode('->', $statement, 2);
46
47
        return \count($parts) > 1 ? ', ' . $this->wrapPath($parts[1]) : '';
48
    }
49
}
50