Passed
Push — master ( 289635...077925 )
by Adrian
02:39
created

QueryBuild::transaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * Author: Adrian Dumitru
5
 * Date: 4/22/2017 4:08 AM
6
 */
7
8
namespace Qpdb\QueryBuilder;
9
10
11
use Qpdb\PdoWrapper\PdoWrapperService;
0 ignored issues
show
Bug introduced by
The type Qpdb\PdoWrapper\PdoWrapperService was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Qpdb\QueryBuilder\Statements\QueryCustom;
13
use Qpdb\QueryBuilder\Statements\QueryDelete;
14
use Qpdb\QueryBuilder\Statements\QueryInsert;
15
use Qpdb\QueryBuilder\Statements\QuerySelect;
16
use Qpdb\QueryBuilder\Statements\QueryUpdate;
17
use Qpdb\QueryBuilder\Statements\Transaction;
18
19
class QueryBuild
20
{
21
22
	/**
23
	 * @var integer
24
	 */
25
	private $queryType;
26
27
	/**
28
	 * QueryBuild constructor.
29
	 * @param $queryType
30
	 */
31
	protected function __construct( $queryType )
32
	{
33
		$this->queryType = $queryType;
34
	}
35
36
	/**
37
	 * @param $table
38
	 * @return QuerySelect
39
	 * @throws Dependencies\QueryException
40
	 */
41
	public static function select( $table )
42
	{
43
		return new QuerySelect( new QueryBuild( 0 ), $table );
44
	}
45
46
	/**
47
	 * @param $table
48
	 * @return QueryUpdate
49
	 * @throws Dependencies\QueryException
50
	 */
51
	public static function update( $table )
52
	{
53
		return new QueryUpdate( new QueryBuild( 0 ), $table );
54
	}
55
56
	/**
57
	 * @param $table
58
	 * @return QueryInsert
59
	 * @throws Dependencies\QueryException
60
	 */
61
	public static function insert( $table )
62
	{
63
		return new QueryInsert( new QueryBuild( 0 ), $table );
64
	}
65
66
	/**
67
	 * @param $table
68
	 * @return QueryDelete
69
	 * @throws Dependencies\QueryException
70
	 */
71
	public static function delete( $table )
72
	{
73
		return new QueryDelete( new QueryBuild( 0 ), $table );
74
	}
75
76
	/**
77
	 * @return string
78
	 */
79
	public static function lastId() {
80
		return PdoWrapperService::getInstance()->lastInsertId();
81
	}
82
83
	/**
84
	 * @param $query
85
	 * @return QueryCustom
86
	 * @throws Dependencies\QueryException
87
	 */
88
	public static function query( $query )
89
	{
90
		return new QueryCustom( new QueryBuild( 1 ), $query );
91
	}
92
93
	/**
94
	 * @return Transaction
95
	 */
96
	public static function transaction()
97
	{
98
		return new Transaction();
99
	}
100
101
	/**
102
	 * @return integer
103
	 */
104
	public function getType()
105
	{
106
		return $this->queryType;
107
	}
108
109
}