Passed
Push — master ( d44413...7ff405 )
by Adrian
04:24
created
sample/autoloader.php 1 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 1 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.
src/Traits/SelectFields.php 1 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.
src/Traits/GroupBy.php 1 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.
src/Traits/Replacement.php 1 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.
src/Traits/Distinct.php 1 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 1 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 1 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.