Completed
Push — master ( 211d4d...735fa4 )
by Woody
10s
created

HasFrom::addFrom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Latitude\QueryBuilder\Query\Capability;
5
6
use Latitude\QueryBuilder\ExpressionInterface;
7
use Latitude\QueryBuilder\StatementInterface;
8
9
use function Latitude\QueryBuilder\identifyAll;
10
use function Latitude\QueryBuilder\listing;
11
12
trait HasFrom
13
{
14
    /** @var StatementInterface[] */
15
    protected $from = [];
16
17 30
    public function from(...$tables): self
18
    {
19 30
        $this->from = identifyAll($tables);
20 30
        return $this;
21
    }
22
23 1
    public function addFrom(...$tables): self
24
    {
25 1
        return $this->from(...array_merge($this->from, $tables));
26
    }
27
28 31
    protected function applyFrom(ExpressionInterface $query): ExpressionInterface
29
    {
30 31
        return $this->from ? $query->append('FROM %s', listing($this->from)) : $query;
31
    }
32
}
33