Completed
Push — master ( e9ffb8...8e1095 )
by Beniamin
02:35
created

DeleteBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 7
dl 0
loc 69
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addDelete() 0 8 2
A doAddDelete() 0 4 1
A getDeleteClauses() 0 4 1
A from() 0 4 1
A addFrom() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\SQLBuilder\QueryBuilder;
13
14
use Phuria\SQLBuilder\Table\AbstractTable;
15
16
/**
17
 * @author Beniamin Jonatan Šimko <[email protected]>
18
 */
19
class DeleteBuilder extends AbstractBuilder implements
20
    Clause\LimitClauseInterface,
21
    Clause\OrderByClauseInterface,
22
    Clause\WhereClauseInterface,
23
    Component\JoinComponentInterface,
24
    Component\TableComponentInterface
25
{
26
    use Clause\LimitClauseTrait;
27
    use Clause\OrderByClauseTrait;
28
    use Clause\WhereClauseTrait;
29
    use Component\JoinComponentTrait;
30
    use Component\ParameterComponentTrait;
31
    use Component\TableComponentTrait;
32
33
    /**
34
     * @var array $deleteClauses
35
     */
36
    private $deleteClauses = [];
37
38
    /**
39
     * @return $this
40
     */
41 1
    public function addDelete()
42
    {
43 1
        foreach (func_get_args() as $clause) {
44 1
            $this->doAddDelete($clause);
45 1
        }
46
47 1
        return $this;
48
    }
49
50
    /**
51
     * @param mixed $clause
52
     */
53 1
    private function doAddDelete($clause)
54
    {
55 1
        $this->deleteClauses[] = $clause;
56 1
    }
57
58
    /**
59
     * @return array
60
     */
61 3
    public function getDeleteClauses()
62
    {
63 3
        return $this->deleteClauses;
64
    }
65
66
    /**
67
     * @param mixed  $table
68
     * @param string $alias
0 ignored issues
show
Documentation introduced by
Should the type for parameter $alias not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
69
     *
70
     * @return AbstractTable
71
     */
72 3
    public function from($table, $alias = null)
73
    {
74 3
        return $this->addFrom($table, $alias);
75
    }
76
77
    /**
78
     * @param mixed  $table
79
     * @param string $alias
0 ignored issues
show
Documentation introduced by
Should the type for parameter $alias not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
80
     *
81
     * @return AbstractTable
82
     */
83 3
    public function addFrom($table, $alias = null)
84
    {
85 3
        return $this->addRootTable($table, $alias);
86
    }
87
}