Passed
Push — master ( af341e...2b2ec9 )
by Jonas
07:18 queued 05:16
created

SqlServerGrammar   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 36
ccs 5
cts 5
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A compileJsonObject() 0 3 1
A compileJsonArray() 0 3 1
A compileJsonValueSelect() 0 5 1
1
<?php
2
3
namespace Staudenmeir\EloquentJsonRelations\Grammars;
4
5
use Illuminate\Database\Query\Grammars\SqlServerGrammar as Base;
6
use RuntimeException;
7
8
class SqlServerGrammar extends Base implements JsonGrammar
9
{
10
    /**
11
     * Compile a "JSON array" statement into SQL.
12
     *
13
     * @param string $column
14
     * @return string
15
     */
16 23
    public function compileJsonArray($column)
17
    {
18 23
        return $this->wrap($column);
19
    }
20
21
    /**
22
     * Compile a "JSON object" statement into SQL.
23
     *
24
     * @param string $column
25
     * @param int $levels
26
     * @return string
27
     */
28
    public function compileJsonObject($column, $levels)
29
    {
30
        throw new RuntimeException('This database is not supported.'); // @codeCoverageIgnore
31
    }
32
33
    /**
34
     * Compile a "JSON value select" statement into SQL.
35
     *
36
     * @param string $column
37
     * @return string
38
     */
39 6
    public function compileJsonValueSelect(string $column): string
40
    {
41 6
        [$field, $path] = $this->wrapJsonFieldAndPath($column);
42
43 6
        return "json_query($field$path)";
44
    }
45
}
46