Completed
Push — master ( fd0133...375486 )
by Beniamin
02:35
created

CompilerPayload::getActualSQL()   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
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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\QueryCompiler;
13
14
use Phuria\SQLBuilder\QueryBuilder\BuilderInterface;
15
16
/**
17
 * @author Beniamin Jonatan Šimko <[email protected]>
18
 */
19
class CompilerPayload
20
{
21
    /**
22
     * @var string
23
     */
24
    private $actualSQL;
25
26
    /**
27
     * @var BuilderInterface
28
     */
29
    private $builder;
30
31
    /**
32
     * @param BuilderInterface $builder
33
     * @param string|null      $actualSQL
34
     */
35 4
    public function __construct(BuilderInterface $builder, $actualSQL = null)
36
    {
37 4
        $this->actualSQL = $actualSQL;
38 4
        $this->builder = $builder;
39 4
    }
40
41
    /**
42
     * @return string
43
     */
44 4
    public function getActualSQL()
45
    {
46 4
        return $this->actualSQL;
47
    }
48
49
    /**
50
     * @return BuilderInterface
51
     */
52 4
    public function getBuilder()
53
    {
54 4
        return $this->builder;
55
    }
56
57
    /**
58
     * @param string $newSQL
59
     *
60
     * @return CompilerPayload
61
     */
62 4
    public function updateSQL($newSQL)
63
    {
64 4
        return new CompilerPayload($this->builder, $newSQL);
65
    }
66
67
    /**
68
     * @param string $newSQL
69
     *
70
     * @return CompilerPayload
71
     */
72 4
    public function appendSQL($newSQL)
73
    {
74 4
        if ($newSQL) {
75 4
            return $this->updateSQL($this->actualSQL . ' ' . $newSQL);
76
        }
77
78
        return $this;
79
    }
80
}