Passed
Branch master (7ff405)
by Adrian
01:44
created
sample/autoloader.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@
 block discarded – undo
10 10
 /**
11 11
  * @param $class
12 12
  */
13
-    function($class) {
13
+	function($class) {
14 14
 
15
-        $nameSpace = str_replace('\\', '/', trim($class, '\\')) . '.php';
16
-        $nameSpace = str_replace('Qpdb/QueryBuilder/', '', $nameSpace);
17
-        $includeFile = __DIR__ . '/../src/' . $nameSpace;
15
+		$nameSpace = str_replace('\\', '/', trim($class, '\\')) . '.php';
16
+		$nameSpace = str_replace('Qpdb/QueryBuilder/', '', $nameSpace);
17
+		$includeFile = __DIR__ . '/../src/' . $nameSpace;
18 18
 
19
-        require_once($includeFile);
19
+		require_once($includeFile);
20 20
 
21
-    }
21
+	}
22 22
 
23 23
 );
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
 /**
11 11
  * @param $class
12 12
  */
13
-    function($class) {
13
+    function( $class ) {
14 14
 
15
-        $nameSpace = str_replace('\\', '/', trim($class, '\\')) . '.php';
16
-        $nameSpace = str_replace('Qpdb/QueryBuilder/', '', $nameSpace);
15
+        $nameSpace = str_replace( '\\', '/', trim( $class, '\\' ) ) . '.php';
16
+        $nameSpace = str_replace( 'Qpdb/QueryBuilder/', '', $nameSpace );
17 17
         $includeFile = __DIR__ . '/../src/' . $nameSpace;
18 18
 
19
-        require_once($includeFile);
19
+        require_once( $includeFile );
20 20
 
21 21
     }
22 22
 
Please login to merge, or discard this patch.
sample/select.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@
 block discarded – undo
8 8
 
9 9
 use Qpdb\QueryBuilder\QueryBuild;
10 10
 
11
-include_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
11
+include_once $_SERVER[ 'DOCUMENT_ROOT' ] . '/vendor/autoload.php';
12 12
 
13 13
 
14
-$query = QueryBuild::select('employees22')->fields('lastName, jobTitle, officeCode')->whereEqual('jobTitle', "Sales Rep")->whereIn('officeCode', [2, 3, 4]);
14
+$query = QueryBuild::select( 'employees22' )->fields( 'lastName, jobTitle, officeCode' )->whereEqual( 'jobTitle', "Sales Rep" )->whereIn( 'officeCode', [ 2, 3, 4 ] );
15 15
 
16 16
 
17
-echo "<pre>" . print_r($query->getSyntax(), 1) . "</pre>";
18
-echo "<pre>" . print_r($query->getBindParams(), 1) . "</pre>";
19
-echo "<pre>" . print_r($query->getSyntax(1), 1) . "</pre>";
20
-echo "<pre>" . print_r($query->execute(), 1) . "</pre>";
21 17
\ No newline at end of file
18
+echo "<pre>" . print_r( $query->getSyntax(), 1 ) . "</pre>";
19
+echo "<pre>" . print_r( $query->getBindParams(), 1 ) . "</pre>";
20
+echo "<pre>" . print_r( $query->getSyntax( 1 ), 1 ) . "</pre>";
21
+echo "<pre>" . print_r( $query->execute(), 1 ) . "</pre>";
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/Traits/InsertMultiple.php 3 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,110 +17,110 @@
 block discarded – undo
17 17
 trait InsertMultiple
18 18
 {
19 19
 
20
-    use Objects;
20
+	use Objects;
21 21
 
22 22
 
23
-    /**
24
-     * @param $fieldsList
25
-     * @param array $rowsForInsert
26
-     * @return $this
27
-     */
28
-    public function fromArray($fieldsList, array $rowsForInsert)
29
-    {
30
-        $this->setFieldsList($fieldsList);
23
+	/**
24
+	 * @param $fieldsList
25
+	 * @param array $rowsForInsert
26
+	 * @return $this
27
+	 */
28
+	public function fromArray($fieldsList, array $rowsForInsert)
29
+	{
30
+		$this->setFieldsList($fieldsList);
31 31
 
32
-        foreach ($rowsForInsert as $row)
33
-            $this->addSingleRow($row);
32
+		foreach ($rowsForInsert as $row)
33
+			$this->addSingleRow($row);
34 34
 
35
-        return $this;
36
-    }
35
+		return $this;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @param $fieldsList
41
-     * @param QuerySelect $query
42
-     * @return $this
43
-     */
44
-    public function fromQuerySelect($fieldsList, QuerySelect $query)
45
-    {
46
-        $this->setFieldsList($fieldsList);
39
+	/**
40
+	 * @param $fieldsList
41
+	 * @param QuerySelect $query
42
+	 * @return $this
43
+	 */
44
+	public function fromQuerySelect($fieldsList, QuerySelect $query)
45
+	{
46
+		$this->setFieldsList($fieldsList);
47 47
 
48
-        foreach ($query->getBindParams() as $key => $value)
49
-            $this->queryStructure->setParams($key, $value);
48
+		foreach ($query->getBindParams() as $key => $value)
49
+			$this->queryStructure->setParams($key, $value);
50 50
 
51
-        $this->queryStructure->replaceElement(QueryStructure::SET_FIELDS, $query);
51
+		$this->queryStructure->replaceElement(QueryStructure::SET_FIELDS, $query);
52 52
 
53
-        return $this;
54
-    }
53
+		return $this;
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * @param string|array $fieldList
59
-     */
60
-    private function setFieldsList($fieldList)
61
-    {
62
-        if (!is_array($fieldList))
63
-            $fieldList = QueryHelper::explode($fieldList);
57
+	/**
58
+	 * @param string|array $fieldList
59
+	 */
60
+	private function setFieldsList($fieldList)
61
+	{
62
+		if (!is_array($fieldList))
63
+			$fieldList = QueryHelper::explode($fieldList);
64 64
 
65
-        $this->queryStructure->replaceElement(QueryStructure::FIELDS, $fieldList);
65
+		$this->queryStructure->replaceElement(QueryStructure::FIELDS, $fieldList);
66 66
 
67
-    }
67
+	}
68 68
 
69
-    /**
70
-     * @param array $rowValues
71
-     * @return $this
72
-     * @throws QueryException
73
-     */
74
-    private function addSingleRow(array $rowValues)
75
-    {
69
+	/**
70
+	 * @param array $rowValues
71
+	 * @return $this
72
+	 * @throws QueryException
73
+	 */
74
+	private function addSingleRow(array $rowValues)
75
+	{
76 76
 
77
-        if ($this->getNumberOfFields() !== count($rowValues))
78
-            throw new QueryException('Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT);
77
+		if ($this->getNumberOfFields() !== count($rowValues))
78
+			throw new QueryException('Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT);
79 79
 
80
-        $pdoRowValues = array();
80
+		$pdoRowValues = array();
81 81
 
82
-        foreach ($rowValues as $value)
83
-            $pdoRowValues[] = $this->queryStructure->bindParam('value', $value);
82
+		foreach ($rowValues as $value)
83
+			$pdoRowValues[] = $this->queryStructure->bindParam('value', $value);
84 84
 
85
-        $pdoRowValuesString = '( ' . QueryHelper::implode($pdoRowValues, ', ') . ' )';
85
+		$pdoRowValuesString = '( ' . QueryHelper::implode($pdoRowValues, ', ') . ' )';
86 86
 
87
-        $this->queryStructure->setElement(QueryStructure::SET_FIELDS, $pdoRowValuesString);
87
+		$this->queryStructure->setElement(QueryStructure::SET_FIELDS, $pdoRowValuesString);
88 88
 
89
-        return $this;
90
-    }
89
+		return $this;
90
+	}
91 91
 
92
-    /**
93
-     * @return string
94
-     */
95
-    private function getInsertMultipleRowsSyntax()
96
-    {
97
-        if (is_a($this->queryStructure->getElement(QueryStructure::SET_FIELDS), QuerySelect::class))
98
-            return $this->getSyntaxWithSelect();
92
+	/**
93
+	 * @return string
94
+	 */
95
+	private function getInsertMultipleRowsSyntax()
96
+	{
97
+		if (is_a($this->queryStructure->getElement(QueryStructure::SET_FIELDS), QuerySelect::class))
98
+			return $this->getSyntaxWithSelect();
99 99
 
100
-        $fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )';
101
-        $values = QueryHelper::implode($this->queryStructure->getElement(QueryStructure::SET_FIELDS), ', ');
100
+		$fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )';
101
+		$values = QueryHelper::implode($this->queryStructure->getElement(QueryStructure::SET_FIELDS), ', ');
102 102
 
103
-        return $fields . ' VALUES ' . $values;
104
-    }
103
+		return $fields . ' VALUES ' . $values;
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * @return string
109
-     */
110
-    private function getSyntaxWithSelect()
111
-    {
112
-        $fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )';
107
+	/**
108
+	 * @return string
109
+	 */
110
+	private function getSyntaxWithSelect()
111
+	{
112
+		$fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )';
113 113
 
114
-        return $fields . ' ' . $this->queryStructure->getElement(QueryStructure::SET_FIELDS)->getSyntax();
115
-    }
114
+		return $fields . ' ' . $this->queryStructure->getElement(QueryStructure::SET_FIELDS)->getSyntax();
115
+	}
116 116
 
117
-    /**
118
-     * @return int
119
-     */
120
-    private function getNumberOfFields()
121
-    {
122
-        return count($this->queryStructure->getElement(QueryStructure::FIELDS));
123
-    }
117
+	/**
118
+	 * @return int
119
+	 */
120
+	private function getNumberOfFields()
121
+	{
122
+		return count($this->queryStructure->getElement(QueryStructure::FIELDS));
123
+	}
124 124
 
125 125
 
126 126
 }
127 127
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
      * @param array $rowsForInsert
26 26
      * @return $this
27 27
      */
28
-    public function fromArray($fieldsList, array $rowsForInsert)
28
+    public function fromArray( $fieldsList, array $rowsForInsert )
29 29
     {
30
-        $this->setFieldsList($fieldsList);
30
+        $this->setFieldsList( $fieldsList );
31 31
 
32
-        foreach ($rowsForInsert as $row)
33
-            $this->addSingleRow($row);
32
+        foreach ( $rowsForInsert as $row )
33
+            $this->addSingleRow( $row );
34 34
 
35 35
         return $this;
36 36
     }
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
      * @param QuerySelect $query
42 42
      * @return $this
43 43
      */
44
-    public function fromQuerySelect($fieldsList, QuerySelect $query)
44
+    public function fromQuerySelect( $fieldsList, QuerySelect $query )
45 45
     {
46
-        $this->setFieldsList($fieldsList);
46
+        $this->setFieldsList( $fieldsList );
47 47
 
48
-        foreach ($query->getBindParams() as $key => $value)
49
-            $this->queryStructure->setParams($key, $value);
48
+        foreach ( $query->getBindParams() as $key => $value )
49
+            $this->queryStructure->setParams( $key, $value );
50 50
 
51
-        $this->queryStructure->replaceElement(QueryStructure::SET_FIELDS, $query);
51
+        $this->queryStructure->replaceElement( QueryStructure::SET_FIELDS, $query );
52 52
 
53 53
         return $this;
54 54
     }
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
     /**
58 58
      * @param string|array $fieldList
59 59
      */
60
-    private function setFieldsList($fieldList)
60
+    private function setFieldsList( $fieldList )
61 61
     {
62
-        if (!is_array($fieldList))
63
-            $fieldList = QueryHelper::explode($fieldList);
62
+        if ( !is_array( $fieldList ) )
63
+            $fieldList = QueryHelper::explode( $fieldList );
64 64
 
65
-        $this->queryStructure->replaceElement(QueryStructure::FIELDS, $fieldList);
65
+        $this->queryStructure->replaceElement( QueryStructure::FIELDS, $fieldList );
66 66
 
67 67
     }
68 68
 
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
      * @return $this
72 72
      * @throws QueryException
73 73
      */
74
-    private function addSingleRow(array $rowValues)
74
+    private function addSingleRow( array $rowValues )
75 75
     {
76 76
 
77
-        if ($this->getNumberOfFields() !== count($rowValues))
78
-            throw new QueryException('Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT);
77
+        if ( $this->getNumberOfFields() !== count( $rowValues ) )
78
+            throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT );
79 79
 
80 80
         $pdoRowValues = array();
81 81
 
82
-        foreach ($rowValues as $value)
83
-            $pdoRowValues[] = $this->queryStructure->bindParam('value', $value);
82
+        foreach ( $rowValues as $value )
83
+            $pdoRowValues[ ] = $this->queryStructure->bindParam( 'value', $value );
84 84
 
85
-        $pdoRowValuesString = '( ' . QueryHelper::implode($pdoRowValues, ', ') . ' )';
85
+        $pdoRowValuesString = '( ' . QueryHelper::implode( $pdoRowValues, ', ' ) . ' )';
86 86
 
87
-        $this->queryStructure->setElement(QueryStructure::SET_FIELDS, $pdoRowValuesString);
87
+        $this->queryStructure->setElement( QueryStructure::SET_FIELDS, $pdoRowValuesString );
88 88
 
89 89
         return $this;
90 90
     }
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
      */
95 95
     private function getInsertMultipleRowsSyntax()
96 96
     {
97
-        if (is_a($this->queryStructure->getElement(QueryStructure::SET_FIELDS), QuerySelect::class))
97
+        if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) )
98 98
             return $this->getSyntaxWithSelect();
99 99
 
100
-        $fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )';
101
-        $values = QueryHelper::implode($this->queryStructure->getElement(QueryStructure::SET_FIELDS), ', ');
100
+        $fields = '( ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::FIELDS ), ', ' ) . ' )';
101
+        $values = QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), ', ' );
102 102
 
103 103
         return $fields . ' VALUES ' . $values;
104 104
     }
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
      */
110 110
     private function getSyntaxWithSelect()
111 111
     {
112
-        $fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )';
112
+        $fields = '( ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::FIELDS ), ', ' ) . ' )';
113 113
 
114
-        return $fields . ' ' . $this->queryStructure->getElement(QueryStructure::SET_FIELDS)->getSyntax();
114
+        return $fields . ' ' . $this->queryStructure->getElement( QueryStructure::SET_FIELDS )->getSyntax();
115 115
     }
116 116
 
117 117
     /**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     private function getNumberOfFields()
121 121
     {
122
-        return count($this->queryStructure->getElement(QueryStructure::FIELDS));
122
+        return count( $this->queryStructure->getElement( QueryStructure::FIELDS ) );
123 123
     }
124 124
 
125 125
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $this->setFieldsList($fieldsList);
31 31
 
32
-        foreach ($rowsForInsert as $row)
33
-            $this->addSingleRow($row);
32
+        foreach ($rowsForInsert as $row) {
33
+                    $this->addSingleRow($row);
34
+        }
34 35
 
35 36
         return $this;
36 37
     }
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
     {
46 47
         $this->setFieldsList($fieldsList);
47 48
 
48
-        foreach ($query->getBindParams() as $key => $value)
49
-            $this->queryStructure->setParams($key, $value);
49
+        foreach ($query->getBindParams() as $key => $value) {
50
+                    $this->queryStructure->setParams($key, $value);
51
+        }
50 52
 
51 53
         $this->queryStructure->replaceElement(QueryStructure::SET_FIELDS, $query);
52 54
 
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
      */
60 62
     private function setFieldsList($fieldList)
61 63
     {
62
-        if (!is_array($fieldList))
63
-            $fieldList = QueryHelper::explode($fieldList);
64
+        if (!is_array($fieldList)) {
65
+                    $fieldList = QueryHelper::explode($fieldList);
66
+        }
64 67
 
65 68
         $this->queryStructure->replaceElement(QueryStructure::FIELDS, $fieldList);
66 69
 
@@ -74,13 +77,15 @@  discard block
 block discarded – undo
74 77
     private function addSingleRow(array $rowValues)
75 78
     {
76 79
 
77
-        if ($this->getNumberOfFields() !== count($rowValues))
78
-            throw new QueryException('Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT);
80
+        if ($this->getNumberOfFields() !== count($rowValues)) {
81
+                    throw new QueryException('Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT);
82
+        }
79 83
 
80 84
         $pdoRowValues = array();
81 85
 
82
-        foreach ($rowValues as $value)
83
-            $pdoRowValues[] = $this->queryStructure->bindParam('value', $value);
86
+        foreach ($rowValues as $value) {
87
+                    $pdoRowValues[] = $this->queryStructure->bindParam('value', $value);
88
+        }
84 89
 
85 90
         $pdoRowValuesString = '( ' . QueryHelper::implode($pdoRowValues, ', ') . ' )';
86 91
 
@@ -94,8 +99,9 @@  discard block
 block discarded – undo
94 99
      */
95 100
     private function getInsertMultipleRowsSyntax()
96 101
     {
97
-        if (is_a($this->queryStructure->getElement(QueryStructure::SET_FIELDS), QuerySelect::class))
98
-            return $this->getSyntaxWithSelect();
102
+        if (is_a($this->queryStructure->getElement(QueryStructure::SET_FIELDS), QuerySelect::class)) {
103
+                    return $this->getSyntaxWithSelect();
104
+        }
99 105
 
100 106
         $fields = '( ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::FIELDS), ', ') . ' )';
101 107
         $values = QueryHelper::implode($this->queryStructure->getElement(QueryStructure::SET_FIELDS), ', ');
Please login to merge, or discard this patch.
src/Traits/SelectFields.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -14,61 +14,61 @@
 block discarded – undo
14 14
 
15 15
 trait SelectFields
16 16
 {
17
-    use Objects;
17
+	use Objects;
18 18
 
19 19
 
20
-    /**
21
-     * @param string|array $fields
22
-     * @return $this
23
-     * @throws QueryException
24
-     */
25
-    public function fields($fields)
26
-    {
20
+	/**
21
+	 * @param string|array $fields
22
+	 * @return $this
23
+	 * @throws QueryException
24
+	 */
25
+	public function fields($fields)
26
+	{
27 27
 
28
-        switch (gettype($fields)) {
29
-            case QueryStructure::ELEMENT_TYPE_ARRAY:
28
+		switch (gettype($fields)) {
29
+			case QueryStructure::ELEMENT_TYPE_ARRAY:
30 30
 
31
-                $fields = $this->prepareArrayFields($fields);
31
+				$fields = $this->prepareArrayFields($fields);
32 32
 
33
-                if (count($fields))
34
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, implode(', ', $fields)); else
35
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
36
-                break;
33
+				if (count($fields))
34
+					$this->queryStructure->setElement(QueryStructure::FIELDS, implode(', ', $fields)); else
35
+					$this->queryStructure->setElement(QueryStructure::FIELDS, '*');
36
+				break;
37 37
 
38
-            case QueryStructure::ELEMENT_TYPE_STRING:
38
+			case QueryStructure::ELEMENT_TYPE_STRING:
39 39
 
40
-                $fields = trim($fields);
41
-                if ('' !== $fields)
42
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, $fields); else
43
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
44
-                break;
40
+				$fields = trim($fields);
41
+				if ('' !== $fields)
42
+					$this->queryStructure->setElement(QueryStructure::FIELDS, $fields); else
43
+					$this->queryStructure->setElement(QueryStructure::FIELDS, '*');
44
+				break;
45 45
 
46
-            default:
47
-                throw new QueryException('Invalid fields parameter type', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
46
+			default:
47
+				throw new QueryException('Invalid fields parameter type', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
48 48
 
49
-        }
49
+		}
50 50
 
51
-        return $this;
52
-    }
51
+		return $this;
52
+	}
53 53
 
54
-    /**
55
-     * @param array $fieldsArray
56
-     * @return array
57
-     * @throws QueryException
58
-     */
59
-    private function prepareArrayFields($fieldsArray = array())
60
-    {
61
-        $prepareArray = [];
54
+	/**
55
+	 * @param array $fieldsArray
56
+	 * @return array
57
+	 * @throws QueryException
58
+	 */
59
+	private function prepareArrayFields($fieldsArray = array())
60
+	{
61
+		$prepareArray = [];
62 62
 
63
-        foreach ($fieldsArray as $field) {
64
-            if (gettype($field) !== QueryStructure::ELEMENT_TYPE_STRING)
65
-                throw new QueryException('Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD);
63
+		foreach ($fieldsArray as $field) {
64
+			if (gettype($field) !== QueryStructure::ELEMENT_TYPE_STRING)
65
+				throw new QueryException('Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD);
66 66
 
67
-            if ('' !== trim($field))
68
-                $prepareArray[] = trim($field);
69
-        }
67
+			if ('' !== trim($field))
68
+				$prepareArray[] = trim($field);
69
+		}
70 70
 
71
-        return $prepareArray;
72
-    }
71
+		return $prepareArray;
72
+	}
73 73
 
74 74
 }
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,29 +22,29 @@  discard block
 block discarded – undo
22 22
      * @return $this
23 23
      * @throws QueryException
24 24
      */
25
-    public function fields($fields)
25
+    public function fields( $fields )
26 26
     {
27 27
 
28
-        switch (gettype($fields)) {
28
+        switch ( gettype( $fields ) ) {
29 29
             case QueryStructure::ELEMENT_TYPE_ARRAY:
30 30
 
31
-                $fields = $this->prepareArrayFields($fields);
31
+                $fields = $this->prepareArrayFields( $fields );
32 32
 
33
-                if (count($fields))
34
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, implode(', ', $fields)); else
35
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
33
+                if ( count( $fields ) )
34
+                    $this->queryStructure->setElement( QueryStructure::FIELDS, implode( ', ', $fields ) ); else
35
+                    $this->queryStructure->setElement( QueryStructure::FIELDS, '*' );
36 36
                 break;
37 37
 
38 38
             case QueryStructure::ELEMENT_TYPE_STRING:
39 39
 
40
-                $fields = trim($fields);
41
-                if ('' !== $fields)
42
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, $fields); else
43
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
40
+                $fields = trim( $fields );
41
+                if ( '' !== $fields )
42
+                    $this->queryStructure->setElement( QueryStructure::FIELDS, $fields ); else
43
+                    $this->queryStructure->setElement( QueryStructure::FIELDS, '*' );
44 44
                 break;
45 45
 
46 46
             default:
47
-                throw new QueryException('Invalid fields parameter type', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
47
+                throw new QueryException( 'Invalid fields parameter type', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY );
48 48
 
49 49
         }
50 50
 
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
      * @return array
57 57
      * @throws QueryException
58 58
      */
59
-    private function prepareArrayFields($fieldsArray = array())
59
+    private function prepareArrayFields( $fieldsArray = array() )
60 60
     {
61
-        $prepareArray = [];
61
+        $prepareArray = [ ];
62 62
 
63
-        foreach ($fieldsArray as $field) {
64
-            if (gettype($field) !== QueryStructure::ELEMENT_TYPE_STRING)
65
-                throw new QueryException('Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD);
63
+        foreach ( $fieldsArray as $field ) {
64
+            if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING )
65
+                throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD );
66 66
 
67
-            if ('' !== trim($field))
68
-                $prepareArray[] = trim($field);
67
+            if ( '' !== trim( $field ) )
68
+                $prepareArray[ ] = trim( $field );
69 69
         }
70 70
 
71 71
         return $prepareArray;
Please login to merge, or discard this patch.
Braces   +16 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,17 +30,21 @@  discard block
 block discarded – undo
30 30
 
31 31
                 $fields = $this->prepareArrayFields($fields);
32 32
 
33
-                if (count($fields))
34
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, implode(', ', $fields)); else
35
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
33
+                if (count($fields)) {
34
+                                    $this->queryStructure->setElement(QueryStructure::FIELDS, implode(', ', $fields));
35
+                } else {
36
+                                        $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
37
+                    }
36 38
                 break;
37 39
 
38 40
             case QueryStructure::ELEMENT_TYPE_STRING:
39 41
 
40 42
                 $fields = trim($fields);
41
-                if ('' !== $fields)
42
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, $fields); else
43
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
43
+                if ('' !== $fields) {
44
+                                    $this->queryStructure->setElement(QueryStructure::FIELDS, $fields);
45
+                } else {
46
+                                        $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
47
+                    }
44 48
                 break;
45 49
 
46 50
             default:
@@ -61,11 +65,13 @@  discard block
 block discarded – undo
61 65
         $prepareArray = [];
62 66
 
63 67
         foreach ($fieldsArray as $field) {
64
-            if (gettype($field) !== QueryStructure::ELEMENT_TYPE_STRING)
65
-                throw new QueryException('Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD);
68
+            if (gettype($field) !== QueryStructure::ELEMENT_TYPE_STRING) {
69
+                            throw new QueryException('Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD);
70
+            }
66 71
 
67
-            if ('' !== trim($field))
68
-                $prepareArray[] = trim($field);
72
+            if ('' !== trim($field)) {
73
+                            $prepareArray[] = trim($field);
74
+            }
69 75
         }
70 76
 
71 77
         return $prepareArray;
Please login to merge, or discard this patch.
src/Traits/GroupBy.php 3 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -15,68 +15,68 @@
 block discarded – undo
15 15
 trait GroupBy
16 16
 {
17 17
 
18
-    use Objects;
18
+	use Objects;
19 19
 
20 20
 
21
-    /**
22
-     * @param $column
23
-     * @param array $allowedColumns
24
-     * @return $this
25
-     * @throws QueryException
26
-     */
27
-    public function groupBy($column, array $allowedColumns = [])
28
-    {
29
-        $column = trim($column);
21
+	/**
22
+	 * @param $column
23
+	 * @param array $allowedColumns
24
+	 * @return $this
25
+	 * @throws QueryException
26
+	 */
27
+	public function groupBy($column, array $allowedColumns = [])
28
+	{
29
+		$column = trim($column);
30 30
 
31
-        if (!$this->validateColumn($column, $allowedColumns))
32
-            throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
31
+		if (!$this->validateColumn($column, $allowedColumns))
32
+			throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
33 33
 
34
-        $this->queryStructure->setElement(QueryStructure::GROUP_BY, $column);
34
+		$this->queryStructure->setElement(QueryStructure::GROUP_BY, $column);
35 35
 
36
-        return $this;
37
-    }
36
+		return $this;
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * @param $column
42
-     * @param array $allowedColumns
43
-     * @return $this
44
-     * @throws QueryException
45
-     */
46
-    public function groupByDesc($column, array $allowedColumns = [])
47
-    {
48
-        $column = trim($column);
40
+	/**
41
+	 * @param $column
42
+	 * @param array $allowedColumns
43
+	 * @return $this
44
+	 * @throws QueryException
45
+	 */
46
+	public function groupByDesc($column, array $allowedColumns = [])
47
+	{
48
+		$column = trim($column);
49 49
 
50
-        if (!$this->validateColumn($column, $allowedColumns))
51
-            throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
50
+		if (!$this->validateColumn($column, $allowedColumns))
51
+			throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
52 52
 
53
-        $this->queryStructure->setElement(QueryStructure::GROUP_BY, $column . ' DESC');
53
+		$this->queryStructure->setElement(QueryStructure::GROUP_BY, $column . ' DESC');
54 54
 
55
-        return $this;
56
-    }
55
+		return $this;
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * @param $expression
61
-     * @return $this
62
-     */
63
-    public function groupByExpression($expression)
64
-    {
65
-        $this->queryStructure->setElement(QueryStructure::GROUP_BY, $expression);
59
+	/**
60
+	 * @param $expression
61
+	 * @return $this
62
+	 */
63
+	public function groupByExpression($expression)
64
+	{
65
+		$this->queryStructure->setElement(QueryStructure::GROUP_BY, $expression);
66 66
 
67
-        return $this;
68
-    }
67
+		return $this;
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return string
73
-     */
74
-    private function getGroupBySyntax()
75
-    {
76
-        if (count($this->queryStructure->getElement(QueryStructure::GROUP_BY)))
77
-            return 'GROUP BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::GROUP_BY), ', ');
71
+	/**
72
+	 * @return string
73
+	 */
74
+	private function getGroupBySyntax()
75
+	{
76
+		if (count($this->queryStructure->getElement(QueryStructure::GROUP_BY)))
77
+			return 'GROUP BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::GROUP_BY), ', ');
78 78
 
79
-        return '';
80
-    }
79
+		return '';
80
+	}
81 81
 
82 82
 }
83 83
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
      * @return $this
25 25
      * @throws QueryException
26 26
      */
27
-    public function groupBy($column, array $allowedColumns = [])
27
+    public function groupBy( $column, array $allowedColumns = [ ] )
28 28
     {
29
-        $column = trim($column);
29
+        $column = trim( $column );
30 30
 
31
-        if (!$this->validateColumn($column, $allowedColumns))
32
-            throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
31
+        if ( !$this->validateColumn( $column, $allowedColumns ) )
32
+            throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
33 33
 
34
-        $this->queryStructure->setElement(QueryStructure::GROUP_BY, $column);
34
+        $this->queryStructure->setElement( QueryStructure::GROUP_BY, $column );
35 35
 
36 36
         return $this;
37 37
     }
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
      * @return $this
44 44
      * @throws QueryException
45 45
      */
46
-    public function groupByDesc($column, array $allowedColumns = [])
46
+    public function groupByDesc( $column, array $allowedColumns = [ ] )
47 47
     {
48
-        $column = trim($column);
48
+        $column = trim( $column );
49 49
 
50
-        if (!$this->validateColumn($column, $allowedColumns))
51
-            throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
50
+        if ( !$this->validateColumn( $column, $allowedColumns ) )
51
+            throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
52 52
 
53
-        $this->queryStructure->setElement(QueryStructure::GROUP_BY, $column . ' DESC');
53
+        $this->queryStructure->setElement( QueryStructure::GROUP_BY, $column . ' DESC' );
54 54
 
55 55
         return $this;
56 56
     }
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
      * @param $expression
61 61
      * @return $this
62 62
      */
63
-    public function groupByExpression($expression)
63
+    public function groupByExpression( $expression )
64 64
     {
65
-        $this->queryStructure->setElement(QueryStructure::GROUP_BY, $expression);
65
+        $this->queryStructure->setElement( QueryStructure::GROUP_BY, $expression );
66 66
 
67 67
         return $this;
68 68
     }
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
      */
74 74
     private function getGroupBySyntax()
75 75
     {
76
-        if (count($this->queryStructure->getElement(QueryStructure::GROUP_BY)))
77
-            return 'GROUP BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::GROUP_BY), ', ');
76
+        if ( count( $this->queryStructure->getElement( QueryStructure::GROUP_BY ) ) )
77
+            return 'GROUP BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::GROUP_BY ), ', ' );
78 78
 
79 79
         return '';
80 80
     }
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $column = trim($column);
30 30
 
31
-        if (!$this->validateColumn($column, $allowedColumns))
32
-            throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
31
+        if (!$this->validateColumn($column, $allowedColumns)) {
32
+                    throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
33
+        }
33 34
 
34 35
         $this->queryStructure->setElement(QueryStructure::GROUP_BY, $column);
35 36
 
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
     {
48 49
         $column = trim($column);
49 50
 
50
-        if (!$this->validateColumn($column, $allowedColumns))
51
-            throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
51
+        if (!$this->validateColumn($column, $allowedColumns)) {
52
+                    throw new QueryException('Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME);
53
+        }
52 54
 
53 55
         $this->queryStructure->setElement(QueryStructure::GROUP_BY, $column . ' DESC');
54 56
 
@@ -73,8 +75,9 @@  discard block
 block discarded – undo
73 75
      */
74 76
     private function getGroupBySyntax()
75 77
     {
76
-        if (count($this->queryStructure->getElement(QueryStructure::GROUP_BY)))
77
-            return 'GROUP BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::GROUP_BY), ', ');
78
+        if (count($this->queryStructure->getElement(QueryStructure::GROUP_BY))) {
79
+                    return 'GROUP BY ' . QueryHelper::implode($this->queryStructure->getElement(QueryStructure::GROUP_BY), ', ');
80
+        }
78 81
 
79 82
         return '';
80 83
     }
Please login to merge, or discard this patch.
src/Traits/Replacement.php 3 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@
 block discarded – undo
16 16
 trait Replacement
17 17
 {
18 18
 
19
-    use Objects;
20
-
21
-    /**
22
-     * @param $syntax
23
-     * @param int $withReplacement
24
-     * @return mixed|string
25
-     */
26
-    private function getSyntaxReplace($syntax, $withReplacement = QueryStatementInterface::REPLACEMENT_NONE)
27
-    {
28
-        $syntax = QueryHelper::clearMultipleSpaces($syntax);
29
-
30
-        if (!$withReplacement)
31
-            return $syntax;
32
-
33
-        return $this->replaceValues($syntax);
34
-    }
35
-
36
-    /**
37
-     * @param $syntax
38
-     * @return string
39
-     */
40
-    private function replaceValues($syntax)
41
-    {
42
-        $bindParams = $this->queryStructure->getElement(QueryStructure::BIND_PARAMS);
43
-        $search = array();
44
-        $replace = array();
45
-        foreach ($bindParams as $key => $value) {
46
-            $search[] = ':' . $key;
47
-            $replace[] = DbConnect::getInstance()->quote($value);
48
-        }
49
-        $syntax = str_ireplace($search, $replace, $syntax);
50
-
51
-        return $syntax;
52
-
53
-    }
19
+	use Objects;
20
+
21
+	/**
22
+	 * @param $syntax
23
+	 * @param int $withReplacement
24
+	 * @return mixed|string
25
+	 */
26
+	private function getSyntaxReplace($syntax, $withReplacement = QueryStatementInterface::REPLACEMENT_NONE)
27
+	{
28
+		$syntax = QueryHelper::clearMultipleSpaces($syntax);
29
+
30
+		if (!$withReplacement)
31
+			return $syntax;
32
+
33
+		return $this->replaceValues($syntax);
34
+	}
35
+
36
+	/**
37
+	 * @param $syntax
38
+	 * @return string
39
+	 */
40
+	private function replaceValues($syntax)
41
+	{
42
+		$bindParams = $this->queryStructure->getElement(QueryStructure::BIND_PARAMS);
43
+		$search = array();
44
+		$replace = array();
45
+		foreach ($bindParams as $key => $value) {
46
+			$search[] = ':' . $key;
47
+			$replace[] = DbConnect::getInstance()->quote($value);
48
+		}
49
+		$syntax = str_ireplace($search, $replace, $syntax);
50
+
51
+		return $syntax;
52
+
53
+	}
54 54
 
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,30 +23,30 @@
 block discarded – undo
23 23
      * @param int $withReplacement
24 24
      * @return mixed|string
25 25
      */
26
-    private function getSyntaxReplace($syntax, $withReplacement = QueryStatementInterface::REPLACEMENT_NONE)
26
+    private function getSyntaxReplace( $syntax, $withReplacement = QueryStatementInterface::REPLACEMENT_NONE )
27 27
     {
28
-        $syntax = QueryHelper::clearMultipleSpaces($syntax);
28
+        $syntax = QueryHelper::clearMultipleSpaces( $syntax );
29 29
 
30
-        if (!$withReplacement)
30
+        if ( !$withReplacement )
31 31
             return $syntax;
32 32
 
33
-        return $this->replaceValues($syntax);
33
+        return $this->replaceValues( $syntax );
34 34
     }
35 35
 
36 36
     /**
37 37
      * @param $syntax
38 38
      * @return string
39 39
      */
40
-    private function replaceValues($syntax)
40
+    private function replaceValues( $syntax )
41 41
     {
42
-        $bindParams = $this->queryStructure->getElement(QueryStructure::BIND_PARAMS);
42
+        $bindParams = $this->queryStructure->getElement( QueryStructure::BIND_PARAMS );
43 43
         $search = array();
44 44
         $replace = array();
45
-        foreach ($bindParams as $key => $value) {
46
-            $search[] = ':' . $key;
47
-            $replace[] = DbConnect::getInstance()->quote($value);
45
+        foreach ( $bindParams as $key => $value ) {
46
+            $search[ ] = ':' . $key;
47
+            $replace[ ] = DbConnect::getInstance()->quote( $value );
48 48
         }
49
-        $syntax = str_ireplace($search, $replace, $syntax);
49
+        $syntax = str_ireplace( $search, $replace, $syntax );
50 50
 
51 51
         return $syntax;
52 52
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@
 block discarded – undo
27 27
     {
28 28
         $syntax = QueryHelper::clearMultipleSpaces($syntax);
29 29
 
30
-        if (!$withReplacement)
31
-            return $syntax;
30
+        if (!$withReplacement) {
31
+                    return $syntax;
32
+        }
32 33
 
33 34
         return $this->replaceValues($syntax);
34 35
     }
Please login to merge, or discard this patch.
src/Traits/Distinct.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -15,60 +15,60 @@
 block discarded – undo
15 15
 trait Distinct
16 16
 {
17 17
 
18
-    use Objects;
19
-
20
-
21
-    /**
22
-     * @return $this
23
-     */
24
-    public function all()
25
-    {
26
-        $this->queryStructure->setElement(QueryStructure::DISTINCT, 0);
27
-
28
-        return $this;
29
-    }
30
-
31
-    /**
32
-     * @return $this
33
-     */
34
-    public function distinct()
35
-    {
36
-        $this->queryStructure->setElement(QueryStructure::DISTINCT, 1);
37
-
38
-        return $this;
39
-    }
40
-
41
-    /**
42
-     * @return $this
43
-     */
44
-    public function distinctRow()
45
-    {
46
-        $this->queryStructure->setElement(QueryStructure::DISTINCT, 2);
47
-
48
-        return $this;
49
-    }
50
-
51
-
52
-    /**
53
-     * @return string
54
-     * @throws QueryException
55
-     */
56
-    private function getDistinctSyntax()
57
-    {
58
-        $useDistinct = $this->queryStructure->getElement(QueryStructure::DISTINCT);
59
-
60
-        switch ($useDistinct) {
61
-            case 0:
62
-                return '';
63
-            case 1:
64
-                return 'DISTINCT';
65
-            case 2:
66
-                return 'DISTINCTROW';
67
-            default:
68
-                throw new QueryException('Invalid distinct type', QueryException::QUERY_ERROR_INVALID_DISTINCT);
69
-        }
70
-
71
-    }
18
+	use Objects;
19
+
20
+
21
+	/**
22
+	 * @return $this
23
+	 */
24
+	public function all()
25
+	{
26
+		$this->queryStructure->setElement(QueryStructure::DISTINCT, 0);
27
+
28
+		return $this;
29
+	}
30
+
31
+	/**
32
+	 * @return $this
33
+	 */
34
+	public function distinct()
35
+	{
36
+		$this->queryStructure->setElement(QueryStructure::DISTINCT, 1);
37
+
38
+		return $this;
39
+	}
40
+
41
+	/**
42
+	 * @return $this
43
+	 */
44
+	public function distinctRow()
45
+	{
46
+		$this->queryStructure->setElement(QueryStructure::DISTINCT, 2);
47
+
48
+		return $this;
49
+	}
50
+
51
+
52
+	/**
53
+	 * @return string
54
+	 * @throws QueryException
55
+	 */
56
+	private function getDistinctSyntax()
57
+	{
58
+		$useDistinct = $this->queryStructure->getElement(QueryStructure::DISTINCT);
59
+
60
+		switch ($useDistinct) {
61
+			case 0:
62
+				return '';
63
+			case 1:
64
+				return 'DISTINCT';
65
+			case 2:
66
+				return 'DISTINCTROW';
67
+			default:
68
+				throw new QueryException('Invalid distinct type', QueryException::QUERY_ERROR_INVALID_DISTINCT);
69
+		}
70
+
71
+	}
72 72
 
73 73
 
74 74
 }
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function all()
25 25
     {
26
-        $this->queryStructure->setElement(QueryStructure::DISTINCT, 0);
26
+        $this->queryStructure->setElement( QueryStructure::DISTINCT, 0 );
27 27
 
28 28
         return $this;
29 29
     }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      */
34 34
     public function distinct()
35 35
     {
36
-        $this->queryStructure->setElement(QueryStructure::DISTINCT, 1);
36
+        $this->queryStructure->setElement( QueryStructure::DISTINCT, 1 );
37 37
 
38 38
         return $this;
39 39
     }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function distinctRow()
45 45
     {
46
-        $this->queryStructure->setElement(QueryStructure::DISTINCT, 2);
46
+        $this->queryStructure->setElement( QueryStructure::DISTINCT, 2 );
47 47
 
48 48
         return $this;
49 49
     }
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
      */
56 56
     private function getDistinctSyntax()
57 57
     {
58
-        $useDistinct = $this->queryStructure->getElement(QueryStructure::DISTINCT);
58
+        $useDistinct = $this->queryStructure->getElement( QueryStructure::DISTINCT );
59 59
 
60
-        switch ($useDistinct) {
60
+        switch ( $useDistinct ) {
61 61
             case 0:
62 62
                 return '';
63 63
             case 1:
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             case 2:
66 66
                 return 'DISTINCTROW';
67 67
             default:
68
-                throw new QueryException('Invalid distinct type', QueryException::QUERY_ERROR_INVALID_DISTINCT);
68
+                throw new QueryException( 'Invalid distinct type', QueryException::QUERY_ERROR_INVALID_DISTINCT );
69 69
         }
70 70
 
71 71
     }
Please login to merge, or discard this patch.
src/Traits/Having.php 2 patches
Indentation   +332 added lines, -332 removed lines patch added patch discarded remove patch
@@ -13,337 +13,337 @@
 block discarded – undo
13 13
 trait Having
14 14
 {
15 15
 
16
-    use Objects;
17
-
18
-
19
-    /**
20
-     * @param $field
21
-     * @param $value
22
-     * @param $glue
23
-     * @return $this
24
-     */
25
-    public function havingEqual($field, $value, $glue = 'AND')
26
-    {
27
-        return $this->having(array($field, $value, '='), $glue);
28
-    }
29
-
30
-    /**
31
-     * @param $field
32
-     * @param $value
33
-     * @return $this
34
-     */
35
-    public function orHavingEqual($field, $value)
36
-    {
37
-        return $this->having(array($field, $value, '='), 'OR');
38
-    }
39
-
40
-    /**
41
-     * @param $field
42
-     * @param $value
43
-     * @param string $glue
44
-     * @return $this
45
-     */
46
-    public function havingNotEqual($field, $value, $glue = 'AND')
47
-    {
48
-        return $this->having(array($field, $value, '<>'), $glue);
49
-    }
50
-
51
-    /**
52
-     * @param $field
53
-     * @param $value
54
-     * @return $this
55
-     */
56
-    public function orHavingNotEqual($field, $value)
57
-    {
58
-        return $this->having(array($field, $value, '<>'), 'OR');
59
-    }
60
-
61
-    /**
62
-     * @param $field
63
-     * @param $value
64
-     * @param string $glue
65
-     * @return $this
66
-     */
67
-    public function havingLessThan($field, $value, $glue = 'AND')
68
-    {
69
-        return $this->having(array($field, $value, '<'), $glue);
70
-    }
71
-
72
-    /**
73
-     * @param $field
74
-     * @param $value
75
-     * @return $this
76
-     */
77
-    public function orHavingLessThan($field, $value)
78
-    {
79
-        return $this->having(array($field, $value, '<'), 'OR');
80
-    }
81
-
82
-    /**
83
-     * @param $field
84
-     * @param $value
85
-     * @param string $glue
86
-     * @return $this
87
-     */
88
-    public function havingLessThanOrEqual($field, $value, $glue = 'AND')
89
-    {
90
-        return $this->having(array($field, $value, '<='), $glue);
91
-    }
92
-
93
-    /**
94
-     * @param $field
95
-     * @param $value
96
-     * @return $this
97
-     */
98
-    public function orHavingLessThanOrEqual($field, $value)
99
-    {
100
-        return $this->having(array($field, $value, '<='), 'OR');
101
-    }
102
-
103
-    /**
104
-     * @param $field
105
-     * @param $value
106
-     * @param string $glue
107
-     * @return $this
108
-     */
109
-    public function havingGreaterThan($field, $value, $glue = 'AND')
110
-    {
111
-        return $this->having(array($field, $value, '>'), $glue);
112
-    }
113
-
114
-    /**
115
-     * @param $field
116
-     * @param $value
117
-     * @return $this
118
-     */
119
-    public function orHavingGreaterThan($field, $value)
120
-    {
121
-        return $this->having(array($field, $value, '>'), 'OR');
122
-    }
123
-
124
-    /**
125
-     * @param $field
126
-     * @param $value
127
-     * @param string $glue
128
-     * @return $this
129
-     */
130
-    public function havingGreaterThanOrEqual($field, $value, $glue = 'AND')
131
-    {
132
-        return $this->having(array($field, $value, '>='), $glue);
133
-    }
134
-
135
-    /**
136
-     * @param $field
137
-     * @param $value
138
-     * @return $this
139
-     */
140
-    public function orHavingGreaterThanOrEqual($field, $value)
141
-    {
142
-        return $this->having(array($field, $value, '>='), 'OR');
143
-    }
144
-
145
-    /**
146
-     * @param $field
147
-     * @param $value
148
-     * @param string $glue
149
-     * @return $this
150
-     */
151
-    public function havingLike($field, $value, $glue = 'AND')
152
-    {
153
-        return $this->having(array($field, $value, 'LIKE'), $glue);
154
-    }
155
-
156
-    /**
157
-     * @param $field
158
-     * @param $value
159
-     * @return $this
160
-     */
161
-    public function orHavingLike($field, $value)
162
-    {
163
-        return $this->having(array($field, $value, 'LIKE'), 'OR');
164
-    }
165
-
166
-    /**
167
-     * @param $field
168
-     * @param $value
169
-     * @param string $glue
170
-     * @return $this
171
-     */
172
-    public function havingNotLike($field, $value, $glue = 'AND')
173
-    {
174
-        return $this->having(array($field, $value, 'NOT LIKE'), $glue);
175
-    }
176
-
177
-    /**
178
-     * @param $field
179
-     * @param $value
180
-     * @return $this
181
-     */
182
-    public function orHavingNotLike($field, $value)
183
-    {
184
-        return $this->having(array($field, $value, 'NOT LIKE'), 'OR');
185
-    }
186
-
187
-    /**
188
-     * @param $field
189
-     * @param $min
190
-     * @param $max
191
-     * @param string $glue
192
-     * @return $this
193
-     */
194
-    public function havingBetween($field, $min, $max, $glue = 'AND')
195
-    {
196
-        return $this->having(array($field, array($min, $max), 'BETWEEN'), $glue);
197
-    }
198
-
199
-    /**
200
-     * @param $field
201
-     * @param $min
202
-     * @param $max
203
-     * @return $this
204
-     */
205
-    public function orHavingBetween($field, $min, $max)
206
-    {
207
-        return $this->having(array($field, array($min, $max), 'BETWEEN'), 'OR');
208
-    }
209
-
210
-    /**
211
-     * @param $field
212
-     * @param $min
213
-     * @param $max
214
-     * @param string $glue
215
-     * @return $this
216
-     */
217
-    public function havingNotBetween($field, $min, $max, $glue = 'AND')
218
-    {
219
-        return $this->having(array($field, array($min, $max), 'NOT BETWEEN'), $glue);
220
-    }
221
-
222
-    /**
223
-     * @param $field
224
-     * @param $min
225
-     * @param $max
226
-     * @return $this
227
-     */
228
-    public function orHavingNotBetween($field, $min, $max)
229
-    {
230
-        return $this->having(array($field, array($min, $max), 'NOT BETWEEN'), 'OR');
231
-    }
232
-
233
-    /**
234
-     * @param $field
235
-     * @param $value
236
-     * @param string $glue
237
-     * @return $this
238
-     */
239
-    public function havingIn($field, $value, $glue = 'AND')
240
-    {
241
-        return $this->having(array($field, $value, 'IN'), $glue);
242
-    }
243
-
244
-    /**
245
-     * @param $field
246
-     * @param $value
247
-     * @return $this
248
-     */
249
-    public function orHavingIn($field, $value)
250
-    {
251
-        return $this->having(array($field, $value, 'IN'), 'OR');
252
-    }
253
-
254
-    /**
255
-     * @param $field
256
-     * @param $value
257
-     * @param string $glue
258
-     * @return $this
259
-     */
260
-    public function havingNotIn($field, $value, $glue = 'AND')
261
-    {
262
-        return $this->having(array($field, $value, 'NOT IN'), $glue);
263
-    }
264
-
265
-    /**
266
-     * @param $field
267
-     * @param $value
268
-     * @return $this
269
-     */
270
-    public function orHavingNotIn($field, $value)
271
-    {
272
-        return $this->having(array($field, $value, 'NOT IN'), 'OR');
273
-    }
274
-
275
-    /**
276
-     * @param $whereString
277
-     * @param array $bindParams
278
-     * @param string $glue
279
-     * @return $this
280
-     */
281
-    public function havingExpression($whereString, array $bindParams = [], $glue = 'AND')
282
-    {
283
-        $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams);
284
-
285
-        return $this->having($whereString, $glue);
286
-    }
287
-
288
-    /**
289
-     * @param $whereString
290
-     * @param array $bindParams
291
-     * @return $this
292
-     */
293
-    public function orHavingExpression($whereString, array $bindParams = [])
294
-    {
295
-        $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams);
296
-
297
-        return $this->having($whereString, 'OR');
298
-    }
299
-
300
-    /**
301
-     * @return $this
302
-     */
303
-    public function havingInvertResult()
304
-    {
305
-        $this->queryStructure->setElement(QueryStructure::HAVING_INVERT, 1);
306
-
307
-        return $this;
308
-    }
309
-
310
-    /**
311
-     * @param string $glue
312
-     * @return $this
313
-     */
314
-    public function havingGroup($glue = 'AND')
315
-    {
316
-        $this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group'));
317
-
318
-        return $this;
319
-    }
320
-
321
-    /**
322
-     * @return $this
323
-     */
324
-    public function orHavingGroup()
325
-    {
326
-        return $this->havingGroup('OR');
327
-    }
328
-
329
-    /**
330
-     * @return $this
331
-     */
332
-    public function havingGroupEnd()
333
-    {
334
-        $this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => '', 'body' => ')', 'type' => 'end_where_group'));
335
-
336
-        return $this;
337
-    }
338
-
339
-    /**
340
-     * @param $param
341
-     * @param string $glue
342
-     * @return $this
343
-     */
344
-    private function having($param, $glue = 'AND')
345
-    {
346
-        return $this->createCondition($param, $glue, QueryStructure::HAVING);
347
-    }
16
+	use Objects;
17
+
18
+
19
+	/**
20
+	 * @param $field
21
+	 * @param $value
22
+	 * @param $glue
23
+	 * @return $this
24
+	 */
25
+	public function havingEqual($field, $value, $glue = 'AND')
26
+	{
27
+		return $this->having(array($field, $value, '='), $glue);
28
+	}
29
+
30
+	/**
31
+	 * @param $field
32
+	 * @param $value
33
+	 * @return $this
34
+	 */
35
+	public function orHavingEqual($field, $value)
36
+	{
37
+		return $this->having(array($field, $value, '='), 'OR');
38
+	}
39
+
40
+	/**
41
+	 * @param $field
42
+	 * @param $value
43
+	 * @param string $glue
44
+	 * @return $this
45
+	 */
46
+	public function havingNotEqual($field, $value, $glue = 'AND')
47
+	{
48
+		return $this->having(array($field, $value, '<>'), $glue);
49
+	}
50
+
51
+	/**
52
+	 * @param $field
53
+	 * @param $value
54
+	 * @return $this
55
+	 */
56
+	public function orHavingNotEqual($field, $value)
57
+	{
58
+		return $this->having(array($field, $value, '<>'), 'OR');
59
+	}
60
+
61
+	/**
62
+	 * @param $field
63
+	 * @param $value
64
+	 * @param string $glue
65
+	 * @return $this
66
+	 */
67
+	public function havingLessThan($field, $value, $glue = 'AND')
68
+	{
69
+		return $this->having(array($field, $value, '<'), $glue);
70
+	}
71
+
72
+	/**
73
+	 * @param $field
74
+	 * @param $value
75
+	 * @return $this
76
+	 */
77
+	public function orHavingLessThan($field, $value)
78
+	{
79
+		return $this->having(array($field, $value, '<'), 'OR');
80
+	}
81
+
82
+	/**
83
+	 * @param $field
84
+	 * @param $value
85
+	 * @param string $glue
86
+	 * @return $this
87
+	 */
88
+	public function havingLessThanOrEqual($field, $value, $glue = 'AND')
89
+	{
90
+		return $this->having(array($field, $value, '<='), $glue);
91
+	}
92
+
93
+	/**
94
+	 * @param $field
95
+	 * @param $value
96
+	 * @return $this
97
+	 */
98
+	public function orHavingLessThanOrEqual($field, $value)
99
+	{
100
+		return $this->having(array($field, $value, '<='), 'OR');
101
+	}
102
+
103
+	/**
104
+	 * @param $field
105
+	 * @param $value
106
+	 * @param string $glue
107
+	 * @return $this
108
+	 */
109
+	public function havingGreaterThan($field, $value, $glue = 'AND')
110
+	{
111
+		return $this->having(array($field, $value, '>'), $glue);
112
+	}
113
+
114
+	/**
115
+	 * @param $field
116
+	 * @param $value
117
+	 * @return $this
118
+	 */
119
+	public function orHavingGreaterThan($field, $value)
120
+	{
121
+		return $this->having(array($field, $value, '>'), 'OR');
122
+	}
123
+
124
+	/**
125
+	 * @param $field
126
+	 * @param $value
127
+	 * @param string $glue
128
+	 * @return $this
129
+	 */
130
+	public function havingGreaterThanOrEqual($field, $value, $glue = 'AND')
131
+	{
132
+		return $this->having(array($field, $value, '>='), $glue);
133
+	}
134
+
135
+	/**
136
+	 * @param $field
137
+	 * @param $value
138
+	 * @return $this
139
+	 */
140
+	public function orHavingGreaterThanOrEqual($field, $value)
141
+	{
142
+		return $this->having(array($field, $value, '>='), 'OR');
143
+	}
144
+
145
+	/**
146
+	 * @param $field
147
+	 * @param $value
148
+	 * @param string $glue
149
+	 * @return $this
150
+	 */
151
+	public function havingLike($field, $value, $glue = 'AND')
152
+	{
153
+		return $this->having(array($field, $value, 'LIKE'), $glue);
154
+	}
155
+
156
+	/**
157
+	 * @param $field
158
+	 * @param $value
159
+	 * @return $this
160
+	 */
161
+	public function orHavingLike($field, $value)
162
+	{
163
+		return $this->having(array($field, $value, 'LIKE'), 'OR');
164
+	}
165
+
166
+	/**
167
+	 * @param $field
168
+	 * @param $value
169
+	 * @param string $glue
170
+	 * @return $this
171
+	 */
172
+	public function havingNotLike($field, $value, $glue = 'AND')
173
+	{
174
+		return $this->having(array($field, $value, 'NOT LIKE'), $glue);
175
+	}
176
+
177
+	/**
178
+	 * @param $field
179
+	 * @param $value
180
+	 * @return $this
181
+	 */
182
+	public function orHavingNotLike($field, $value)
183
+	{
184
+		return $this->having(array($field, $value, 'NOT LIKE'), 'OR');
185
+	}
186
+
187
+	/**
188
+	 * @param $field
189
+	 * @param $min
190
+	 * @param $max
191
+	 * @param string $glue
192
+	 * @return $this
193
+	 */
194
+	public function havingBetween($field, $min, $max, $glue = 'AND')
195
+	{
196
+		return $this->having(array($field, array($min, $max), 'BETWEEN'), $glue);
197
+	}
198
+
199
+	/**
200
+	 * @param $field
201
+	 * @param $min
202
+	 * @param $max
203
+	 * @return $this
204
+	 */
205
+	public function orHavingBetween($field, $min, $max)
206
+	{
207
+		return $this->having(array($field, array($min, $max), 'BETWEEN'), 'OR');
208
+	}
209
+
210
+	/**
211
+	 * @param $field
212
+	 * @param $min
213
+	 * @param $max
214
+	 * @param string $glue
215
+	 * @return $this
216
+	 */
217
+	public function havingNotBetween($field, $min, $max, $glue = 'AND')
218
+	{
219
+		return $this->having(array($field, array($min, $max), 'NOT BETWEEN'), $glue);
220
+	}
221
+
222
+	/**
223
+	 * @param $field
224
+	 * @param $min
225
+	 * @param $max
226
+	 * @return $this
227
+	 */
228
+	public function orHavingNotBetween($field, $min, $max)
229
+	{
230
+		return $this->having(array($field, array($min, $max), 'NOT BETWEEN'), 'OR');
231
+	}
232
+
233
+	/**
234
+	 * @param $field
235
+	 * @param $value
236
+	 * @param string $glue
237
+	 * @return $this
238
+	 */
239
+	public function havingIn($field, $value, $glue = 'AND')
240
+	{
241
+		return $this->having(array($field, $value, 'IN'), $glue);
242
+	}
243
+
244
+	/**
245
+	 * @param $field
246
+	 * @param $value
247
+	 * @return $this
248
+	 */
249
+	public function orHavingIn($field, $value)
250
+	{
251
+		return $this->having(array($field, $value, 'IN'), 'OR');
252
+	}
253
+
254
+	/**
255
+	 * @param $field
256
+	 * @param $value
257
+	 * @param string $glue
258
+	 * @return $this
259
+	 */
260
+	public function havingNotIn($field, $value, $glue = 'AND')
261
+	{
262
+		return $this->having(array($field, $value, 'NOT IN'), $glue);
263
+	}
264
+
265
+	/**
266
+	 * @param $field
267
+	 * @param $value
268
+	 * @return $this
269
+	 */
270
+	public function orHavingNotIn($field, $value)
271
+	{
272
+		return $this->having(array($field, $value, 'NOT IN'), 'OR');
273
+	}
274
+
275
+	/**
276
+	 * @param $whereString
277
+	 * @param array $bindParams
278
+	 * @param string $glue
279
+	 * @return $this
280
+	 */
281
+	public function havingExpression($whereString, array $bindParams = [], $glue = 'AND')
282
+	{
283
+		$whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams);
284
+
285
+		return $this->having($whereString, $glue);
286
+	}
287
+
288
+	/**
289
+	 * @param $whereString
290
+	 * @param array $bindParams
291
+	 * @return $this
292
+	 */
293
+	public function orHavingExpression($whereString, array $bindParams = [])
294
+	{
295
+		$whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams);
296
+
297
+		return $this->having($whereString, 'OR');
298
+	}
299
+
300
+	/**
301
+	 * @return $this
302
+	 */
303
+	public function havingInvertResult()
304
+	{
305
+		$this->queryStructure->setElement(QueryStructure::HAVING_INVERT, 1);
306
+
307
+		return $this;
308
+	}
309
+
310
+	/**
311
+	 * @param string $glue
312
+	 * @return $this
313
+	 */
314
+	public function havingGroup($glue = 'AND')
315
+	{
316
+		$this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group'));
317
+
318
+		return $this;
319
+	}
320
+
321
+	/**
322
+	 * @return $this
323
+	 */
324
+	public function orHavingGroup()
325
+	{
326
+		return $this->havingGroup('OR');
327
+	}
328
+
329
+	/**
330
+	 * @return $this
331
+	 */
332
+	public function havingGroupEnd()
333
+	{
334
+		$this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => '', 'body' => ')', 'type' => 'end_where_group'));
335
+
336
+		return $this;
337
+	}
338
+
339
+	/**
340
+	 * @param $param
341
+	 * @param string $glue
342
+	 * @return $this
343
+	 */
344
+	private function having($param, $glue = 'AND')
345
+	{
346
+		return $this->createCondition($param, $glue, QueryStructure::HAVING);
347
+	}
348 348
 
349 349
 }
350 350
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
      * @param $glue
23 23
      * @return $this
24 24
      */
25
-    public function havingEqual($field, $value, $glue = 'AND')
25
+    public function havingEqual( $field, $value, $glue = 'AND' )
26 26
     {
27
-        return $this->having(array($field, $value, '='), $glue);
27
+        return $this->having( array( $field, $value, '=' ), $glue );
28 28
     }
29 29
 
30 30
     /**
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
      * @param $value
33 33
      * @return $this
34 34
      */
35
-    public function orHavingEqual($field, $value)
35
+    public function orHavingEqual( $field, $value )
36 36
     {
37
-        return $this->having(array($field, $value, '='), 'OR');
37
+        return $this->having( array( $field, $value, '=' ), 'OR' );
38 38
     }
39 39
 
40 40
     /**
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
      * @param string $glue
44 44
      * @return $this
45 45
      */
46
-    public function havingNotEqual($field, $value, $glue = 'AND')
46
+    public function havingNotEqual( $field, $value, $glue = 'AND' )
47 47
     {
48
-        return $this->having(array($field, $value, '<>'), $glue);
48
+        return $this->having( array( $field, $value, '<>' ), $glue );
49 49
     }
50 50
 
51 51
     /**
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
      * @param $value
54 54
      * @return $this
55 55
      */
56
-    public function orHavingNotEqual($field, $value)
56
+    public function orHavingNotEqual( $field, $value )
57 57
     {
58
-        return $this->having(array($field, $value, '<>'), 'OR');
58
+        return $this->having( array( $field, $value, '<>' ), 'OR' );
59 59
     }
60 60
 
61 61
     /**
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
      * @param string $glue
65 65
      * @return $this
66 66
      */
67
-    public function havingLessThan($field, $value, $glue = 'AND')
67
+    public function havingLessThan( $field, $value, $glue = 'AND' )
68 68
     {
69
-        return $this->having(array($field, $value, '<'), $glue);
69
+        return $this->having( array( $field, $value, '<' ), $glue );
70 70
     }
71 71
 
72 72
     /**
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
      * @param $value
75 75
      * @return $this
76 76
      */
77
-    public function orHavingLessThan($field, $value)
77
+    public function orHavingLessThan( $field, $value )
78 78
     {
79
-        return $this->having(array($field, $value, '<'), 'OR');
79
+        return $this->having( array( $field, $value, '<' ), 'OR' );
80 80
     }
81 81
 
82 82
     /**
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      * @param string $glue
86 86
      * @return $this
87 87
      */
88
-    public function havingLessThanOrEqual($field, $value, $glue = 'AND')
88
+    public function havingLessThanOrEqual( $field, $value, $glue = 'AND' )
89 89
     {
90
-        return $this->having(array($field, $value, '<='), $glue);
90
+        return $this->having( array( $field, $value, '<=' ), $glue );
91 91
     }
92 92
 
93 93
     /**
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
      * @param $value
96 96
      * @return $this
97 97
      */
98
-    public function orHavingLessThanOrEqual($field, $value)
98
+    public function orHavingLessThanOrEqual( $field, $value )
99 99
     {
100
-        return $this->having(array($field, $value, '<='), 'OR');
100
+        return $this->having( array( $field, $value, '<=' ), 'OR' );
101 101
     }
102 102
 
103 103
     /**
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
      * @param string $glue
107 107
      * @return $this
108 108
      */
109
-    public function havingGreaterThan($field, $value, $glue = 'AND')
109
+    public function havingGreaterThan( $field, $value, $glue = 'AND' )
110 110
     {
111
-        return $this->having(array($field, $value, '>'), $glue);
111
+        return $this->having( array( $field, $value, '>' ), $glue );
112 112
     }
113 113
 
114 114
     /**
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
      * @param $value
117 117
      * @return $this
118 118
      */
119
-    public function orHavingGreaterThan($field, $value)
119
+    public function orHavingGreaterThan( $field, $value )
120 120
     {
121
-        return $this->having(array($field, $value, '>'), 'OR');
121
+        return $this->having( array( $field, $value, '>' ), 'OR' );
122 122
     }
123 123
 
124 124
     /**
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
      * @param string $glue
128 128
      * @return $this
129 129
      */
130
-    public function havingGreaterThanOrEqual($field, $value, $glue = 'AND')
130
+    public function havingGreaterThanOrEqual( $field, $value, $glue = 'AND' )
131 131
     {
132
-        return $this->having(array($field, $value, '>='), $glue);
132
+        return $this->having( array( $field, $value, '>=' ), $glue );
133 133
     }
134 134
 
135 135
     /**
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
      * @param $value
138 138
      * @return $this
139 139
      */
140
-    public function orHavingGreaterThanOrEqual($field, $value)
140
+    public function orHavingGreaterThanOrEqual( $field, $value )
141 141
     {
142
-        return $this->having(array($field, $value, '>='), 'OR');
142
+        return $this->having( array( $field, $value, '>=' ), 'OR' );
143 143
     }
144 144
 
145 145
     /**
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      * @param string $glue
149 149
      * @return $this
150 150
      */
151
-    public function havingLike($field, $value, $glue = 'AND')
151
+    public function havingLike( $field, $value, $glue = 'AND' )
152 152
     {
153
-        return $this->having(array($field, $value, 'LIKE'), $glue);
153
+        return $this->having( array( $field, $value, 'LIKE' ), $glue );
154 154
     }
155 155
 
156 156
     /**
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
      * @param $value
159 159
      * @return $this
160 160
      */
161
-    public function orHavingLike($field, $value)
161
+    public function orHavingLike( $field, $value )
162 162
     {
163
-        return $this->having(array($field, $value, 'LIKE'), 'OR');
163
+        return $this->having( array( $field, $value, 'LIKE' ), 'OR' );
164 164
     }
165 165
 
166 166
     /**
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
      * @param string $glue
170 170
      * @return $this
171 171
      */
172
-    public function havingNotLike($field, $value, $glue = 'AND')
172
+    public function havingNotLike( $field, $value, $glue = 'AND' )
173 173
     {
174
-        return $this->having(array($field, $value, 'NOT LIKE'), $glue);
174
+        return $this->having( array( $field, $value, 'NOT LIKE' ), $glue );
175 175
     }
176 176
 
177 177
     /**
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
      * @param $value
180 180
      * @return $this
181 181
      */
182
-    public function orHavingNotLike($field, $value)
182
+    public function orHavingNotLike( $field, $value )
183 183
     {
184
-        return $this->having(array($field, $value, 'NOT LIKE'), 'OR');
184
+        return $this->having( array( $field, $value, 'NOT LIKE' ), 'OR' );
185 185
     }
186 186
 
187 187
     /**
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
      * @param string $glue
192 192
      * @return $this
193 193
      */
194
-    public function havingBetween($field, $min, $max, $glue = 'AND')
194
+    public function havingBetween( $field, $min, $max, $glue = 'AND' )
195 195
     {
196
-        return $this->having(array($field, array($min, $max), 'BETWEEN'), $glue);
196
+        return $this->having( array( $field, array( $min, $max ), 'BETWEEN' ), $glue );
197 197
     }
198 198
 
199 199
     /**
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
      * @param $max
203 203
      * @return $this
204 204
      */
205
-    public function orHavingBetween($field, $min, $max)
205
+    public function orHavingBetween( $field, $min, $max )
206 206
     {
207
-        return $this->having(array($field, array($min, $max), 'BETWEEN'), 'OR');
207
+        return $this->having( array( $field, array( $min, $max ), 'BETWEEN' ), 'OR' );
208 208
     }
209 209
 
210 210
     /**
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
      * @param string $glue
215 215
      * @return $this
216 216
      */
217
-    public function havingNotBetween($field, $min, $max, $glue = 'AND')
217
+    public function havingNotBetween( $field, $min, $max, $glue = 'AND' )
218 218
     {
219
-        return $this->having(array($field, array($min, $max), 'NOT BETWEEN'), $glue);
219
+        return $this->having( array( $field, array( $min, $max ), 'NOT BETWEEN' ), $glue );
220 220
     }
221 221
 
222 222
     /**
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
      * @param $max
226 226
      * @return $this
227 227
      */
228
-    public function orHavingNotBetween($field, $min, $max)
228
+    public function orHavingNotBetween( $field, $min, $max )
229 229
     {
230
-        return $this->having(array($field, array($min, $max), 'NOT BETWEEN'), 'OR');
230
+        return $this->having( array( $field, array( $min, $max ), 'NOT BETWEEN' ), 'OR' );
231 231
     }
232 232
 
233 233
     /**
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
      * @param string $glue
237 237
      * @return $this
238 238
      */
239
-    public function havingIn($field, $value, $glue = 'AND')
239
+    public function havingIn( $field, $value, $glue = 'AND' )
240 240
     {
241
-        return $this->having(array($field, $value, 'IN'), $glue);
241
+        return $this->having( array( $field, $value, 'IN' ), $glue );
242 242
     }
243 243
 
244 244
     /**
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
      * @param $value
247 247
      * @return $this
248 248
      */
249
-    public function orHavingIn($field, $value)
249
+    public function orHavingIn( $field, $value )
250 250
     {
251
-        return $this->having(array($field, $value, 'IN'), 'OR');
251
+        return $this->having( array( $field, $value, 'IN' ), 'OR' );
252 252
     }
253 253
 
254 254
     /**
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
      * @param string $glue
258 258
      * @return $this
259 259
      */
260
-    public function havingNotIn($field, $value, $glue = 'AND')
260
+    public function havingNotIn( $field, $value, $glue = 'AND' )
261 261
     {
262
-        return $this->having(array($field, $value, 'NOT IN'), $glue);
262
+        return $this->having( array( $field, $value, 'NOT IN' ), $glue );
263 263
     }
264 264
 
265 265
     /**
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
      * @param $value
268 268
      * @return $this
269 269
      */
270
-    public function orHavingNotIn($field, $value)
270
+    public function orHavingNotIn( $field, $value )
271 271
     {
272
-        return $this->having(array($field, $value, 'NOT IN'), 'OR');
272
+        return $this->having( array( $field, $value, 'NOT IN' ), 'OR' );
273 273
     }
274 274
 
275 275
     /**
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
      * @param string $glue
279 279
      * @return $this
280 280
      */
281
-    public function havingExpression($whereString, array $bindParams = [], $glue = 'AND')
281
+    public function havingExpression( $whereString, array $bindParams = [ ], $glue = 'AND' )
282 282
     {
283
-        $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams);
283
+        $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams );
284 284
 
285
-        return $this->having($whereString, $glue);
285
+        return $this->having( $whereString, $glue );
286 286
     }
287 287
 
288 288
     /**
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
      * @param array $bindParams
291 291
      * @return $this
292 292
      */
293
-    public function orHavingExpression($whereString, array $bindParams = [])
293
+    public function orHavingExpression( $whereString, array $bindParams = [ ] )
294 294
     {
295
-        $whereString = $this->queryStructure->bindParamsExpression($whereString, $bindParams);
295
+        $whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams );
296 296
 
297
-        return $this->having($whereString, 'OR');
297
+        return $this->having( $whereString, 'OR' );
298 298
     }
299 299
 
300 300
     /**
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      */
303 303
     public function havingInvertResult()
304 304
     {
305
-        $this->queryStructure->setElement(QueryStructure::HAVING_INVERT, 1);
305
+        $this->queryStructure->setElement( QueryStructure::HAVING_INVERT, 1 );
306 306
 
307 307
         return $this;
308 308
     }
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
      * @param string $glue
312 312
      * @return $this
313 313
      */
314
-    public function havingGroup($glue = 'AND')
314
+    public function havingGroup( $glue = 'AND' )
315 315
     {
316
-        $this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => $glue, 'body' => '(', 'type' => 'start_where_group'));
316
+        $this->queryStructure->setElement( QueryStructure::HAVING, array( 'glue' => $glue, 'body' => '(', 'type' => 'start_where_group' ) );
317 317
 
318 318
         return $this;
319 319
     }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      */
324 324
     public function orHavingGroup()
325 325
     {
326
-        return $this->havingGroup('OR');
326
+        return $this->havingGroup( 'OR' );
327 327
     }
328 328
 
329 329
     /**
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public function havingGroupEnd()
333 333
     {
334
-        $this->queryStructure->setElement(QueryStructure::HAVING, array('glue' => '', 'body' => ')', 'type' => 'end_where_group'));
334
+        $this->queryStructure->setElement( QueryStructure::HAVING, array( 'glue' => '', 'body' => ')', 'type' => 'end_where_group' ) );
335 335
 
336 336
         return $this;
337 337
     }
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
      * @param string $glue
342 342
      * @return $this
343 343
      */
344
-    private function having($param, $glue = 'AND')
344
+    private function having( $param, $glue = 'AND' )
345 345
     {
346
-        return $this->createCondition($param, $glue, QueryStructure::HAVING);
346
+        return $this->createCondition( $param, $glue, QueryStructure::HAVING );
347 347
     }
348 348
 
349 349
 }
350 350
\ No newline at end of file
Please login to merge, or discard this patch.
src/Traits/WhereAndHavingBuilder.php 3 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -17,167 +17,167 @@
 block discarded – undo
17 17
 trait WhereAndHavingBuilder
18 18
 {
19 19
 
20
-    use Objects;
21
-
22
-
23
-    /**
24
-     * @param $param
25
-     * @param string $glue
26
-     * @param $clauseType
27
-     * @return $this
28
-     */
29
-    protected function createCondition($param, $glue = 'AND', $clauseType)
30
-    {
31
-
32
-        if (!is_array($param)) {
33
-            $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => trim($param), 'type' => 'cond'));
34
-
35
-            return $this;
36
-        }
37
-
38
-        $param = $this->validateWhereParam($param);
39
-
40
-        $field = $param[0];
41
-        $value = $param[1];
42
-        $operator = $param[2];
43
-
44
-        switch ($operator) {
45
-            case 'BETWEEN':
46
-            case 'NOT BETWEEN':
47
-            case '!BETWEEN':
48
-                $min = $value[0];
49
-                $max = $value[1];
50
-                $body = [$field, $operator, $this->queryStructure->bindParam('min', $min), 'AND', $this->queryStructure->bindParam('max', $max)];
51
-                $body = implode(' ', $body);
52
-                $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
53
-                break;
54
-
55
-            case 'IN':
56
-            case 'NOT IN':
57
-            case '!IN':
58
-                if (is_a($value, QuerySelect::class))
59
-                    return $this->inSelectObject($field, $value, $operator, $glue, $clauseType); elseif (is_array($value))
60
-                    return $this->inArray($field, $value, $operator, $glue, $clauseType);
61
-                break;
62
-
63
-            default:
64
-                $valuePdoString = $this->queryStructure->bindParam($field, $value);
65
-                $body = $field . ' ' . $operator . ' ' . $valuePdoString;
66
-                $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
67
-
68
-        }
69
-
70
-        return $this;
71
-
72
-    }
73
-
74
-
75
-    /**
76
-     * @param $field
77
-     * @param QuerySelect $subquerySelect
78
-     * @param $operator
79
-     * @param string $glue
80
-     * @param $clauseType
81
-     * @return $this
82
-     */
83
-    private function inSelectObject($field, QuerySelect $subquerySelect, $operator, $glue = 'AND', $clauseType)
84
-    {
85
-        $subquerySelectParams = $subquerySelect->getBindParams();
86
-        foreach ($subquerySelectParams as $key => $value) {
87
-            $this->queryStructure->setParams($key, $value);
88
-        }
89
-        $body = [$field, $operator, '( ', $subquerySelect->getSyntax(), ' )'];
90
-        $body = implode(' ', $body);
91
-        $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
92
-
93
-        return $this;
94
-    }
95
-
96
-    /**
97
-     * @param $field
98
-     * @param array $value
99
-     * @param $operator
100
-     * @param $glue
101
-     * @param $clauseType
102
-     * @return $this
103
-     */
104
-    private function inArray($field, array $value, $operator, $glue, $clauseType)
105
-    {
106
-        $pdoArray = array();
107
-        foreach ($value as $item) {
108
-            $pdoArray[] = $this->queryStructure->bindParam('a', $item);
109
-        }
110
-        $body = [$field, $operator, '( ' . implode(', ', $pdoArray) . ' )'];
111
-        $body = implode(' ', $body);
112
-        $body = QueryHelper::clearMultipleSpaces($body);
113
-        $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
114
-
115
-        return $this;
116
-    }
117
-
118
-
119
-    /**
120
-     * @return bool|mixed|string
121
-     */
122
-    private function getWhereSyntax()
123
-    {
124
-        return $this->getWhereAndHavingSyntax(QueryStructure::WHERE);
125
-    }
126
-
127
-    /**
128
-     * @return bool|mixed|string
129
-     */
130
-    private function getHavingSyntax()
131
-    {
132
-        return $this->getWhereAndHavingSyntax(QueryStructure::HAVING);
133
-    }
134
-
135
-    /**
136
-     * @param $clauseType
137
-     * @return bool|mixed|string
138
-     */
139
-    private function getWhereAndHavingSyntax($clauseType)
140
-    {
141
-        if (count($this->queryStructure->getElement($clauseType)) == 0)
142
-            return '';
143
-
144
-        $where = '';
145
-        $last_type = 'where_start';
146
-        foreach ($this->queryStructure->getElement($clauseType) as $where_cond) {
147
-            $glue = $where_cond['glue'];
148
-            if ($last_type == 'where_start' || $last_type == 'start_where_group') {
149
-                $glue = '';
150
-            }
151
-            $where .= ' ' . $glue . ' ' . $where_cond['body'];
152
-            $last_type = $where_cond['type'];
153
-        }
154
-
155
-        if ($this->queryStructure->getElement($clauseType . '_invert')) {
156
-            $where = ' NOT ( ' . $where . ' ) ';
157
-        }
158
-
159
-        $where = 'WHERE ' . $where;
160
-
161
-        return QueryHelper::clearMultipleSpaces($where);
162
-    }
163
-
164
-    /**
165
-     * @param $param
166
-     * @return array
167
-     * @throws QueryException
168
-     */
169
-    private function validateWhereParam($param)
170
-    {
171
-        if (count($param) < 2)
172
-            throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
173
-
174
-        if (count($param) == 2)
175
-            $param[] = '=';
176
-
177
-        $param[2] = trim(strtoupper($param[2]));
178
-        $param[2] = QueryHelper::clearMultipleSpaces($param[2]);
179
-
180
-        return $param;
181
-    }
20
+	use Objects;
21
+
22
+
23
+	/**
24
+	 * @param $param
25
+	 * @param string $glue
26
+	 * @param $clauseType
27
+	 * @return $this
28
+	 */
29
+	protected function createCondition($param, $glue = 'AND', $clauseType)
30
+	{
31
+
32
+		if (!is_array($param)) {
33
+			$this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => trim($param), 'type' => 'cond'));
34
+
35
+			return $this;
36
+		}
37
+
38
+		$param = $this->validateWhereParam($param);
39
+
40
+		$field = $param[0];
41
+		$value = $param[1];
42
+		$operator = $param[2];
43
+
44
+		switch ($operator) {
45
+			case 'BETWEEN':
46
+			case 'NOT BETWEEN':
47
+			case '!BETWEEN':
48
+				$min = $value[0];
49
+				$max = $value[1];
50
+				$body = [$field, $operator, $this->queryStructure->bindParam('min', $min), 'AND', $this->queryStructure->bindParam('max', $max)];
51
+				$body = implode(' ', $body);
52
+				$this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
53
+				break;
54
+
55
+			case 'IN':
56
+			case 'NOT IN':
57
+			case '!IN':
58
+				if (is_a($value, QuerySelect::class))
59
+					return $this->inSelectObject($field, $value, $operator, $glue, $clauseType); elseif (is_array($value))
60
+					return $this->inArray($field, $value, $operator, $glue, $clauseType);
61
+				break;
62
+
63
+			default:
64
+				$valuePdoString = $this->queryStructure->bindParam($field, $value);
65
+				$body = $field . ' ' . $operator . ' ' . $valuePdoString;
66
+				$this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
67
+
68
+		}
69
+
70
+		return $this;
71
+
72
+	}
73
+
74
+
75
+	/**
76
+	 * @param $field
77
+	 * @param QuerySelect $subquerySelect
78
+	 * @param $operator
79
+	 * @param string $glue
80
+	 * @param $clauseType
81
+	 * @return $this
82
+	 */
83
+	private function inSelectObject($field, QuerySelect $subquerySelect, $operator, $glue = 'AND', $clauseType)
84
+	{
85
+		$subquerySelectParams = $subquerySelect->getBindParams();
86
+		foreach ($subquerySelectParams as $key => $value) {
87
+			$this->queryStructure->setParams($key, $value);
88
+		}
89
+		$body = [$field, $operator, '( ', $subquerySelect->getSyntax(), ' )'];
90
+		$body = implode(' ', $body);
91
+		$this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
92
+
93
+		return $this;
94
+	}
95
+
96
+	/**
97
+	 * @param $field
98
+	 * @param array $value
99
+	 * @param $operator
100
+	 * @param $glue
101
+	 * @param $clauseType
102
+	 * @return $this
103
+	 */
104
+	private function inArray($field, array $value, $operator, $glue, $clauseType)
105
+	{
106
+		$pdoArray = array();
107
+		foreach ($value as $item) {
108
+			$pdoArray[] = $this->queryStructure->bindParam('a', $item);
109
+		}
110
+		$body = [$field, $operator, '( ' . implode(', ', $pdoArray) . ' )'];
111
+		$body = implode(' ', $body);
112
+		$body = QueryHelper::clearMultipleSpaces($body);
113
+		$this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
114
+
115
+		return $this;
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return bool|mixed|string
121
+	 */
122
+	private function getWhereSyntax()
123
+	{
124
+		return $this->getWhereAndHavingSyntax(QueryStructure::WHERE);
125
+	}
126
+
127
+	/**
128
+	 * @return bool|mixed|string
129
+	 */
130
+	private function getHavingSyntax()
131
+	{
132
+		return $this->getWhereAndHavingSyntax(QueryStructure::HAVING);
133
+	}
134
+
135
+	/**
136
+	 * @param $clauseType
137
+	 * @return bool|mixed|string
138
+	 */
139
+	private function getWhereAndHavingSyntax($clauseType)
140
+	{
141
+		if (count($this->queryStructure->getElement($clauseType)) == 0)
142
+			return '';
143
+
144
+		$where = '';
145
+		$last_type = 'where_start';
146
+		foreach ($this->queryStructure->getElement($clauseType) as $where_cond) {
147
+			$glue = $where_cond['glue'];
148
+			if ($last_type == 'where_start' || $last_type == 'start_where_group') {
149
+				$glue = '';
150
+			}
151
+			$where .= ' ' . $glue . ' ' . $where_cond['body'];
152
+			$last_type = $where_cond['type'];
153
+		}
154
+
155
+		if ($this->queryStructure->getElement($clauseType . '_invert')) {
156
+			$where = ' NOT ( ' . $where . ' ) ';
157
+		}
158
+
159
+		$where = 'WHERE ' . $where;
160
+
161
+		return QueryHelper::clearMultipleSpaces($where);
162
+	}
163
+
164
+	/**
165
+	 * @param $param
166
+	 * @return array
167
+	 * @throws QueryException
168
+	 */
169
+	private function validateWhereParam($param)
170
+	{
171
+		if (count($param) < 2)
172
+			throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
173
+
174
+		if (count($param) == 2)
175
+			$param[] = '=';
176
+
177
+		$param[2] = trim(strtoupper($param[2]));
178
+		$param[2] = QueryHelper::clearMultipleSpaces($param[2]);
179
+
180
+		return $param;
181
+	}
182 182
 
183 183
 }
184 184
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -26,44 +26,44 @@  discard block
 block discarded – undo
26 26
      * @param $clauseType
27 27
      * @return $this
28 28
      */
29
-    protected function createCondition($param, $glue = 'AND', $clauseType)
29
+    protected function createCondition( $param, $glue = 'AND', $clauseType )
30 30
     {
31 31
 
32
-        if (!is_array($param)) {
33
-            $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => trim($param), 'type' => 'cond'));
32
+        if ( !is_array( $param ) ) {
33
+            $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => trim( $param ), 'type' => 'cond' ) );
34 34
 
35 35
             return $this;
36 36
         }
37 37
 
38
-        $param = $this->validateWhereParam($param);
38
+        $param = $this->validateWhereParam( $param );
39 39
 
40
-        $field = $param[0];
41
-        $value = $param[1];
42
-        $operator = $param[2];
40
+        $field = $param[ 0 ];
41
+        $value = $param[ 1 ];
42
+        $operator = $param[ 2 ];
43 43
 
44
-        switch ($operator) {
44
+        switch ( $operator ) {
45 45
             case 'BETWEEN':
46 46
             case 'NOT BETWEEN':
47 47
             case '!BETWEEN':
48
-                $min = $value[0];
49
-                $max = $value[1];
50
-                $body = [$field, $operator, $this->queryStructure->bindParam('min', $min), 'AND', $this->queryStructure->bindParam('max', $max)];
51
-                $body = implode(' ', $body);
52
-                $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
48
+                $min = $value[ 0 ];
49
+                $max = $value[ 1 ];
50
+                $body = [ $field, $operator, $this->queryStructure->bindParam( 'min', $min ), 'AND', $this->queryStructure->bindParam( 'max', $max ) ];
51
+                $body = implode( ' ', $body );
52
+                $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) );
53 53
                 break;
54 54
 
55 55
             case 'IN':
56 56
             case 'NOT IN':
57 57
             case '!IN':
58
-                if (is_a($value, QuerySelect::class))
59
-                    return $this->inSelectObject($field, $value, $operator, $glue, $clauseType); elseif (is_array($value))
60
-                    return $this->inArray($field, $value, $operator, $glue, $clauseType);
58
+                if ( is_a( $value, QuerySelect::class ) )
59
+                    return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType ); elseif ( is_array( $value ) )
60
+                    return $this->inArray( $field, $value, $operator, $glue, $clauseType );
61 61
                 break;
62 62
 
63 63
             default:
64
-                $valuePdoString = $this->queryStructure->bindParam($field, $value);
64
+                $valuePdoString = $this->queryStructure->bindParam( $field, $value );
65 65
                 $body = $field . ' ' . $operator . ' ' . $valuePdoString;
66
-                $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
66
+                $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) );
67 67
 
68 68
         }
69 69
 
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
      * @param $clauseType
81 81
      * @return $this
82 82
      */
83
-    private function inSelectObject($field, QuerySelect $subquerySelect, $operator, $glue = 'AND', $clauseType)
83
+    private function inSelectObject( $field, QuerySelect $subquerySelect, $operator, $glue = 'AND', $clauseType )
84 84
     {
85 85
         $subquerySelectParams = $subquerySelect->getBindParams();
86
-        foreach ($subquerySelectParams as $key => $value) {
87
-            $this->queryStructure->setParams($key, $value);
86
+        foreach ( $subquerySelectParams as $key => $value ) {
87
+            $this->queryStructure->setParams( $key, $value );
88 88
         }
89
-        $body = [$field, $operator, '( ', $subquerySelect->getSyntax(), ' )'];
90
-        $body = implode(' ', $body);
91
-        $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
89
+        $body = [ $field, $operator, '( ', $subquerySelect->getSyntax(), ' )' ];
90
+        $body = implode( ' ', $body );
91
+        $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) );
92 92
 
93 93
         return $this;
94 94
     }
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
      * @param $clauseType
102 102
      * @return $this
103 103
      */
104
-    private function inArray($field, array $value, $operator, $glue, $clauseType)
104
+    private function inArray( $field, array $value, $operator, $glue, $clauseType )
105 105
     {
106 106
         $pdoArray = array();
107
-        foreach ($value as $item) {
108
-            $pdoArray[] = $this->queryStructure->bindParam('a', $item);
107
+        foreach ( $value as $item ) {
108
+            $pdoArray[ ] = $this->queryStructure->bindParam( 'a', $item );
109 109
         }
110
-        $body = [$field, $operator, '( ' . implode(', ', $pdoArray) . ' )'];
111
-        $body = implode(' ', $body);
112
-        $body = QueryHelper::clearMultipleSpaces($body);
113
-        $this->queryStructure->setElement($clauseType, array('glue' => $glue, 'body' => $body, 'type' => 'cond'));
110
+        $body = [ $field, $operator, '( ' . implode( ', ', $pdoArray ) . ' )' ];
111
+        $body = implode( ' ', $body );
112
+        $body = QueryHelper::clearMultipleSpaces( $body );
113
+        $this->queryStructure->setElement( $clauseType, array( 'glue' => $glue, 'body' => $body, 'type' => 'cond' ) );
114 114
 
115 115
         return $this;
116 116
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     private function getWhereSyntax()
123 123
     {
124
-        return $this->getWhereAndHavingSyntax(QueryStructure::WHERE);
124
+        return $this->getWhereAndHavingSyntax( QueryStructure::WHERE );
125 125
     }
126 126
 
127 127
     /**
@@ -129,36 +129,36 @@  discard block
 block discarded – undo
129 129
      */
130 130
     private function getHavingSyntax()
131 131
     {
132
-        return $this->getWhereAndHavingSyntax(QueryStructure::HAVING);
132
+        return $this->getWhereAndHavingSyntax( QueryStructure::HAVING );
133 133
     }
134 134
 
135 135
     /**
136 136
      * @param $clauseType
137 137
      * @return bool|mixed|string
138 138
      */
139
-    private function getWhereAndHavingSyntax($clauseType)
139
+    private function getWhereAndHavingSyntax( $clauseType )
140 140
     {
141
-        if (count($this->queryStructure->getElement($clauseType)) == 0)
141
+        if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 )
142 142
             return '';
143 143
 
144 144
         $where = '';
145 145
         $last_type = 'where_start';
146
-        foreach ($this->queryStructure->getElement($clauseType) as $where_cond) {
147
-            $glue = $where_cond['glue'];
148
-            if ($last_type == 'where_start' || $last_type == 'start_where_group') {
146
+        foreach ( $this->queryStructure->getElement( $clauseType ) as $where_cond ) {
147
+            $glue = $where_cond[ 'glue' ];
148
+            if ( $last_type == 'where_start' || $last_type == 'start_where_group' ) {
149 149
                 $glue = '';
150 150
             }
151
-            $where .= ' ' . $glue . ' ' . $where_cond['body'];
152
-            $last_type = $where_cond['type'];
151
+            $where .= ' ' . $glue . ' ' . $where_cond[ 'body' ];
152
+            $last_type = $where_cond[ 'type' ];
153 153
         }
154 154
 
155
-        if ($this->queryStructure->getElement($clauseType . '_invert')) {
155
+        if ( $this->queryStructure->getElement( $clauseType . '_invert' ) ) {
156 156
             $where = ' NOT ( ' . $where . ' ) ';
157 157
         }
158 158
 
159 159
         $where = 'WHERE ' . $where;
160 160
 
161
-        return QueryHelper::clearMultipleSpaces($where);
161
+        return QueryHelper::clearMultipleSpaces( $where );
162 162
     }
163 163
 
164 164
     /**
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
      * @return array
167 167
      * @throws QueryException
168 168
      */
169
-    private function validateWhereParam($param)
169
+    private function validateWhereParam( $param )
170 170
     {
171
-        if (count($param) < 2)
172
-            throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
171
+        if ( count( $param ) < 2 )
172
+            throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY );
173 173
 
174
-        if (count($param) == 2)
175
-            $param[] = '=';
174
+        if ( count( $param ) == 2 )
175
+            $param[ ] = '=';
176 176
 
177
-        $param[2] = trim(strtoupper($param[2]));
178
-        $param[2] = QueryHelper::clearMultipleSpaces($param[2]);
177
+        $param[ 2 ] = trim( strtoupper( $param[ 2 ] ) );
178
+        $param[ 2 ] = QueryHelper::clearMultipleSpaces( $param[ 2 ] );
179 179
 
180 180
         return $param;
181 181
     }
Please login to merge, or discard this patch.
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,9 +55,11 @@  discard block
 block discarded – undo
55 55
             case 'IN':
56 56
             case 'NOT IN':
57 57
             case '!IN':
58
-                if (is_a($value, QuerySelect::class))
59
-                    return $this->inSelectObject($field, $value, $operator, $glue, $clauseType); elseif (is_array($value))
60
-                    return $this->inArray($field, $value, $operator, $glue, $clauseType);
58
+                if (is_a($value, QuerySelect::class)) {
59
+                                    return $this->inSelectObject($field, $value, $operator, $glue, $clauseType);
60
+                } elseif (is_array($value)) {
61
+                                        return $this->inArray($field, $value, $operator, $glue, $clauseType);
62
+                    }
61 63
                 break;
62 64
 
63 65
             default:
@@ -138,8 +140,9 @@  discard block
 block discarded – undo
138 140
      */
139 141
     private function getWhereAndHavingSyntax($clauseType)
140 142
     {
141
-        if (count($this->queryStructure->getElement($clauseType)) == 0)
142
-            return '';
143
+        if (count($this->queryStructure->getElement($clauseType)) == 0) {
144
+                    return '';
145
+        }
143 146
 
144 147
         $where = '';
145 148
         $last_type = 'where_start';
@@ -168,11 +171,13 @@  discard block
 block discarded – undo
168 171
      */
169 172
     private function validateWhereParam($param)
170 173
     {
171
-        if (count($param) < 2)
172
-            throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
174
+        if (count($param) < 2) {
175
+                    throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
176
+        }
173 177
 
174
-        if (count($param) == 2)
175
-            $param[] = '=';
178
+        if (count($param) == 2) {
179
+                    $param[] = '=';
180
+        }
176 181
 
177 182
         $param[2] = trim(strtoupper($param[2]));
178 183
         $param[2] = QueryHelper::clearMultipleSpaces($param[2]);
Please login to merge, or discard this patch.