HasSupportCommands::raw()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 14
ccs 6
cts 6
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\AQL;
6
7
use LaravelFreelancerNL\FluentAQL\Clauses\RawClause;
8
use LaravelFreelancerNL\FluentAQL\Exceptions\BindException;
9
use LaravelFreelancerNL\FluentAQL\Expressions\BindExpression;
10
use LaravelFreelancerNL\FluentAQL\Expressions\Expression;
11
use LaravelFreelancerNL\FluentAQL\Expressions\LiteralExpression;
12
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
13
14
/**
15
 * Trait hasFunctions.
16
 *
17
 * AQL Function API calls.
18
 */
19
trait HasSupportCommands
20
{
21
    abstract public function addCommand($command);
22
23
    /**
24
     * @param object|array<mixed>|string|int|float|bool|null $data
25
     */
26
    abstract public function bind(
27
        object|array|string|int|float|bool|null $data,
28
        string $to = null
29
    ): BindExpression;
30
31
    /**
32
     * @param array<object|array<mixed>|string|int|float|bool|null> $binds
33
     * @param array<string, string|Expression|QueryBuilder> $collections
34
     * @throws BindException
35
     */
36 3
    public function raw(
37
        string $aql,
38
        array $binds = [],
39
        array $collections = []
40
    ): self {
41 3
        $this->bindArrayValues($binds);
0 ignored issues
show
Bug introduced by
It seems like bindArrayValues() 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

41
        $this->/** @scrutinizer ignore-call */ 
42
               bindArrayValues($binds);
Loading history...
42
43 3
        foreach ($collections as $mode => $modeCollections) {
44 1
            $this->registerCollections($modeCollections, $mode);
45
        }
46
47 3
        $this->addCommand(new RawClause($aql));
48
49 3
        return $this;
50
    }
51
52
    abstract public function registerCollections($collections, $mode = 'write');
53
54
    /**
55
     * @param array<array-key, array<array-key, mixed>|null|object|scalar> $binds
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key, array<a...ed>|null|object|scalar> at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key, array<array-key, mixed>|null|object|scalar>.
Loading history...
56
     * @param array<string, string|Expression|QueryBuilder> $collections
57
     * @throws BindException
58
     */
59 3
    public function rawExpression(
60
        string $aql,
61
        array $binds = [],
62
        array $collections = []
63
    ): LiteralExpression {
64 3
        $this->bindArrayValues($binds);
65
66 3
        foreach ($collections as $mode => $modeCollections) {
67 1
            $this->registerCollections($modeCollections, $mode);
68
        }
69
70 3
        return new LiteralExpression($aql);
71
    }
72
}
73