Union   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 28
ccs 12
cts 14
cp 0.8571
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A assemble() 0 17 5
1
<?php
2
3
namespace Nip\Database\Query\Select;
4
5
use Nip\Database\Query\Select;
6
7
class Union extends Select
8
{
9
    protected $_query1;
10
    protected $_query2;
11
12 1
    public function __construct($query1, $query2)
13
    {
14 1
        $this->_query1 = $query1;
15 1
        $this->_query2 = $query2;
16 1
    }
17
18 1
    public function assemble()
19
    {
20 1
        $query = ($this->_query1 instanceof Union) ? "(" . $this->_query1 . ")" : $this->_query1;
21 1
        $query .= " UNION ";
22 1
        $query .= ($this->_query2 instanceof Union) ? "(" . $this->_query2 . ")" : $this->_query2;
23
24 1
        $order = $this->parseOrder();
25
26 1
        if (!empty($order)) {
27
            $query .= " ORDER BY $order";
28
        }
29
30 1
        if (!empty($this->parts['limit'])) {
31
            $query .= " LIMIT {$this->parts['limit']}";
32
        }
33
34 1
        return $query;
35
    }
36
}
37