Utilities::withLogIdentifier()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * Author: Adrian Dumitru
5
 * Date: 5/26/2017 11:00 PM
6
 */
7
8
namespace Qpdb\QueryBuilder\Traits;
9
10
11
use Qpdb\QueryBuilder\Dependencies\QueryStructure;
12
13
/**
14
 * Trait Utilities
15
 * @package Qpdb\QueryBuilder\Traits
16
 * @property QueryStructure $queryStructure
17
 */
18
trait Utilities
19
{
20
21
	/**
22
	 * @return $this
23
	 * @throws \Qpdb\QueryBuilder\Dependencies\QueryException
24
	 */
25
	public function explain()
26
	{
27
		$this->queryStructure->setElement( QueryStructure::EXPLAIN, 1 );
28
29
		return $this;
30
	}
31
32
	/**
33
	 * @return string
34
	 */
35
	protected function getExplainSyntax()
36
	{
37
		if ( $this->queryStructure->getElement( QueryStructure::EXPLAIN ) )
38
			return 'EXPLAIN';
39
40
		return '';
41
	}
42
43
	/**
44
	 * @param string $comment
45
	 * @return $this
46
	 * @throws \Qpdb\QueryBuilder\Dependencies\QueryException
47
	 */
48
	public function withComment( $comment = '' )
49
	{
50
		$this->queryStructure->setElement( QueryStructure::QUERY_COMMENT, $comment );
51
52
		return $this;
53
	}
54
55
	/**
56
	 * @param string $identifier
57
	 * @return $this
58
	 * @throws \Qpdb\QueryBuilder\Dependencies\QueryException
59
	 */
60
	public function withLogIdentifier( $identifier = null )
61
	{
62
		$this->queryStructure->setElement( QueryStructure::QUERY_IDENTIFIER, $identifier );
63
64
		return $this;
65
	}
66
67
}