MySQLUpdateQuery::getSQL()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 13
ccs 7
cts 9
cp 0.7778
crap 3.0987
rs 10
1
<?php
2
3
namespace mindplay\sql\mysql;
4
5
use mindplay\sql\model\components\Limit;
6
use mindplay\sql\model\components\Order;
7
use mindplay\sql\model\query\UpdateQuery;
8
9
class MySQLUpdateQuery extends UpdateQuery
10
{
11
    use Order;
12
    use Limit;
13
14 1
    public function getSQL(): string
15
    {
16 1
        $update = parent::getSQL();
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
            ? "\nLIMIT {$this->limit}"
24 1
            : ''; // no limit
25
26 1
        return "{$update}{$order}{$limit}";
27
    }
28
}
29