RemoveClause::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 3
b 0
f 0
nc 1
nop 2
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\FluentAQL\Clauses;
6
7
use LaravelFreelancerNL\FluentAQL\Expressions\Expression;
8
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
9
10
class RemoveClause extends Clause
11
{
12
    /**
13
     * @var object|string|mixed[] $document
14
     */
15
    protected array|object|string $document;
16
17
    protected string|QueryBuilder|Expression $collection;
18
19
    /**
20
     * @param array<mixed>|object|string $document
21
     */
22 2
    public function __construct(
23
        array|object|string $document,
24
        string|QueryBuilder|Expression $collection
25
    ) {
26 2
        parent::__construct();
27
28 2
        $this->document = $document;
29 2
        $this->collection = $collection;
30
    }
31
32 2
    public function compile(QueryBuilder $queryBuilder): string
33
    {
34 2
        $this->document = $queryBuilder->normalizeArgument(
35 2
            $this->document,
36 2
            ['RegisteredVariable', 'Key', 'Object', 'Bind']
37
        );
38 2
        $queryBuilder->registerCollections($this->collection);
39 2
        $this->collection = $queryBuilder->normalizeArgument($this->collection, ['Collection', 'Bind']);
40
41 2
        return "REMOVE {$this->document->compile($queryBuilder)} IN {$this->collection->compile($queryBuilder)}";
42
    }
43
}
44