Completed
Push — master ( 226980...c1625e )
by Hong
02:50
created

PreviousTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setPrevious() 0 5 1
A hasPrevious() 0 4 1
A getPrevious() 0 4 1
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Query
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Query\Traits;
16
17
use Phossa2\Query\Interfaces\StatementInterface;
18
19
/**
20
 * PreviousTrait
21
 *
22
 * Dealing with multiple statements, e.g.
23
 *
24
 * - SELECT ... UNION ... SELECT
25
 * - INSERT INTO ... SELECT
26
 *
27
 * @package Phossa2\Query
28
 * @author  Hong Zhang <[email protected]>
29
 * @version 2.0.0
30
 * @since   2.0.0 added
31
 */
32
trait PreviousTrait
33
{
34
    /**
35
     * Previous statement used in UNION/UNION ALL
36
     *
37
     * @var    StatementInterface
38
     * @access protected
39
     */
40
    protected $previous;
41
42
    /**
43
     * Set previous statement
44
     *
45
     * @param  StatementInterface $stmt
46
     * @return $this
47
     * @access protected
48
     */
49
    protected function setPrevious(StatementInterface $stmt)
50
    {
51
        $this->previous = $stmt;
52
        return $this;
53
    }
54
55
    /**
56
     * Has previous statement ?
57
     *
58
     * @return bool
59
     * @access protected
60
     */
61
    protected function hasPrevious()/*# : bool */
62
    {
63
        return null !== $this->previous;
64
    }
65
66
    /**
67
     * Get previous statement
68
     *
69
     * @return StatementInterface
70
     * @access protected
71
     */
72
    protected function getPrevious()/*# : StatementInterface */
73
    {
74
        return $this->previous;
75
    }
76
}
77