DeleteQuery::toSql()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Database\Query;
3
4
use Wandu\Database\Contracts\QueryInterface;
5
use Wandu\Database\Query\Expression\HasWhereExpression;
6
use Wandu\Database\Support\Helper;
7
8
class DeleteQuery extends HasWhereExpression implements QueryInterface
9
{
10
    /** @var string */
11
    protected $table;
12
13
    /**
14
     * @param string $table
15
     */
16 2
    public function __construct($table)
17
    {
18 2
        $this->table = $table;
19 2
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 2
    public function toSql()
25
    {
26 2
        $parts = ['DELETE FROM ' . Helper::normalizeName($this->table)];
27 2
        if ($part = parent::toSql()) {
28 2
            $parts[] = $part;
29
        }
30 2
        return implode(' ', $parts);
31
    }
32
}
33