Completed
Push — master ( f707f5...a08928 )
by Rasmus
02:27
created

DeleteQuery   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 92.31%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
wmc 5
lcom 1
cbo 1
ccs 12
cts 13
cp 0.9231
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getSQL() 0 19 5
1
<?php
2
3
namespace mindplay\sql\model\query;
4
5
/**
6
 * This class represents a DELETE query.
7
 */
8
class DeleteQuery extends ProjectionQuery
9
{
10 1
    public function getSQL()
11
    {
12 1
        $delete = "DELETE FROM " . $this->buildNodes();
13
14 1
        $where = count($this->conditions)
15 1
            ? "\nWHERE " . $this->buildConditions()
16 1
            : ''; // no conditions present
17
18 1
        $order = count($this->order)
19
            ? "\nORDER BY " . $this->buildOrderTerms()
20 1
            : ''; // no order terms
21
22 1
        $limit = $this->limit !== null
23 1
            ? "\nLIMIT {$this->limit}"
24 1
            . ($this->offset !== null ? " OFFSET {$this->offset}" : '')
25 1
            : ''; // no limit or offset
26
27 1
        return "{$delete}{$where}{$order}{$limit}";
28
    }
29
}
30