DeleteQuery   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toSql() 0 8 2
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