DeleteBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 45
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequiredParts() 0 3 1
A getInitialParts() 0 3 1
A getLastParts() 0 3 1
A getPartBuilders() 0 8 1
1
<?php
2
/**
3
 * Copyright 2021 Aleksandar Panic
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace ArekX\PQL\Drivers\Pdo\MySql\Builders;
19
20
use ArekX\PQL\Drivers\Pdo\MySql\Builders\Traits\ConditionTrait;
21
use ArekX\PQL\Drivers\Pdo\MySql\Builders\Traits\FromPartTrait;
22
use ArekX\PQL\Drivers\Pdo\MySql\Builders\Traits\JoinTrait;
23
use ArekX\PQL\Drivers\Pdo\MySql\Builders\Traits\NumberPartTrait;
24
use ArekX\PQL\Drivers\Pdo\MySql\Builders\Traits\WhereTrait;
25
use ArekX\PQL\Sql\Query\Delete;
26
27
/**
28
 * Represents a query builder for building a DELETE query.
29
 *
30
 * @see Delete
31
 */
32
class DeleteBuilder extends QueryPartBuilder
33
{
34
    use FromPartTrait;
35
    use ConditionTrait;
36
    use JoinTrait;
37
    use WhereTrait;
38
    use NumberPartTrait;
39
40
    /**
41
     * @inheritDoc
42
     */
43 13
    protected function getInitialParts(): array
44
    {
45 13
        return ['DELETE'];
46
    }
47
48
    /**
49
     * @inheritDoc
50
     */
51 13
    protected function getPartBuilders(): array
52
    {
53 13
        return [
54 13
            'from' => fn($part, $state) => $this->buildFrom($part, $state),
55 13
            'join' => fn($part, $state) => $this->buildJoin($part, $state),
56 13
            'where' => fn($part, $state) => $this->buildWhere($part, $state),
57 13
            'limit' => fn($part) => $this->buildLimit($part),
58 13
            'offset' => fn($part) => $this->buildOffset($part),
59 13
        ];
60
    }
61
62
63
    /**
64
     * @inheritDoc
65
     */
66 13
    protected function getRequiredParts(): array
67
    {
68 13
        return ['from'];
69
    }
70
71
    /**
72
     * @inheritDoc
73
     */
74 13
    protected function getLastParts(): array
75
    {
76 13
        return [];
77
    }
78
}
79