Completed
Push — master ( b54f87...bde51f )
by Beniamin
04:50
created

TableComponentTrait::getQueryBuilder()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
nc 1
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\SQLBuilder\QueryBuilder\Component;
13
14
use Phuria\SQLBuilder\QueryBuilder\AbstractBuilder;
15
use Phuria\SQLBuilder\Table\AbstractTable;
16
use Phuria\SQLBuilder\TableFactory\TableFactoryInterface;
17
18
/**
19
 * @author Beniamin Jonatan Šimko <[email protected]>
20
 */
21
trait TableComponentTrait
22
{
23
    /**
24
     * @var AbstractTable[] $tables
25
     */
26
    private $rootTables = [];
27
28
    /**
29
     * @return TableFactoryInterface
30
     */
31
    abstract protected function getTableFactory();
32
33
    /**
34
     * @return AbstractBuilder
35
     */
36
    abstract public function getQueryBuilder();
37
38
    /**
39
     * @param mixed $table
40
     *
41
     * @return AbstractTable
42
     */
43 26
    protected function addRootTable($table)
44
    {
45 26
        $this->rootTables[] = $table = $this->getTableFactory()->createNewTable($table, $this->getQueryBuilder());
46
47 26
        return $table;
48
    }
49
50
    /**
51
     * @return AbstractTable[]
52
     */
53 27
    public function getRootTables()
54
    {
55 27
        return $this->rootTables;
56
    }
57
}