GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( a2bb11...f0f593 )
by Samuel
03:12
created
tests/Core/Database/Abstraction/InsertQueryBuilderTest.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -12,54 +12,54 @@
 block discarded – undo
12 12
 use EmmetBlue\Core\Database\Abstraction\InsertQueryBuilder;
13 13
 
14 14
 /**
15
-  * class QueryBuilderTest.
16
-  *
17
-  * @author Samuel Adeshina <[email protected]>
18
-  *
19
-  * @since v0.0.1 27/05/2016 14:27
20
-  */
15
+ * class QueryBuilderTest.
16
+ *
17
+ * @author Samuel Adeshina <[email protected]>
18
+ *
19
+ * @since v0.0.1 27/05/2016 14:27
20
+ */
21 21
  class InsertQueryBuilderTest extends \PHPUnit_Framework_TestCase
22 22
  {
23
-     public function testInsertBuilderWithOnlyConstructorParameter()
24
-     {
25
-         $queryBuilder = new InsertQueryBuilder('tbl_name');
23
+	 public function testInsertBuilderWithOnlyConstructorParameter()
24
+	 {
25
+		 $queryBuilder = new InsertQueryBuilder('tbl_name');
26 26
 
27
-         $builtQuery = (string) $queryBuilder;
28
-         $expectedQuery = 'INSERT INTO tbl_name';
27
+		 $builtQuery = (string) $queryBuilder;
28
+		 $expectedQuery = 'INSERT INTO tbl_name';
29 29
 
30
-         $this->assertEquals($expectedQuery, $builtQuery);
31
-     }
30
+		 $this->assertEquals($expectedQuery, $builtQuery);
31
+	 }
32 32
 
33
-     public function testInsertBuilderWithIntoMethod()
34
-     {
35
-         $queryBuilder = new InsertQueryBuilder();
36
-         $queryBuilder = $queryBuilder->into('tbl_name');
33
+	 public function testInsertBuilderWithIntoMethod()
34
+	 {
35
+		 $queryBuilder = new InsertQueryBuilder();
36
+		 $queryBuilder = $queryBuilder->into('tbl_name');
37 37
 
38
-         $builtQuery = (string) $queryBuilder;
39
-         $expectedQuery = 'INSERT INTO tbl_name';
38
+		 $builtQuery = (string) $queryBuilder;
39
+		 $expectedQuery = 'INSERT INTO tbl_name';
40 40
 
41
-         $this->assertEquals($expectedQuery, $builtQuery);
42
-     }
41
+		 $this->assertEquals($expectedQuery, $builtQuery);
42
+	 }
43 43
 
44
-     public function testInsertBuilderWithIntoAndTableColumnsMethod()
45
-     {
46
-         $queryBuilder = new InsertQueryBuilder();
47
-         $queryBuilder = $queryBuilder->into('tbl_name', ['tbl_col1', 'tbl_col2']);
44
+	 public function testInsertBuilderWithIntoAndTableColumnsMethod()
45
+	 {
46
+		 $queryBuilder = new InsertQueryBuilder();
47
+		 $queryBuilder = $queryBuilder->into('tbl_name', ['tbl_col1', 'tbl_col2']);
48 48
 
49
-         $builtQuery = (string) $queryBuilder;
50
-         $expectedQuery = 'INSERT INTO tbl_name(tbl_col1,tbl_col2)';
49
+		 $builtQuery = (string) $queryBuilder;
50
+		 $expectedQuery = 'INSERT INTO tbl_name(tbl_col1,tbl_col2)';
51 51
 
52
-         $this->assertEquals($expectedQuery, $builtQuery);
53
-     }
52
+		 $this->assertEquals($expectedQuery, $builtQuery);
53
+	 }
54 54
 
55
-     public function testInsertBuilderWithConstructorParameterAndValuesKeyword()
56
-     {
57
-         $queryBuilder = new InsertQueryBuilder('tbl_name');
58
-         $queryBuilder = $queryBuilder->values(['tbl_col_val1', 'tbl_col_val2']);
55
+	 public function testInsertBuilderWithConstructorParameterAndValuesKeyword()
56
+	 {
57
+		 $queryBuilder = new InsertQueryBuilder('tbl_name');
58
+		 $queryBuilder = $queryBuilder->values(['tbl_col_val1', 'tbl_col_val2']);
59 59
 
60
-         $expectedQuery = 'INSERT INTO tbl_name VALUES (tbl_col_val1,tbl_col_val2)';
61
-         $builtQuery = (string) $queryBuilder;
60
+		 $expectedQuery = 'INSERT INTO tbl_name VALUES (tbl_col_val1,tbl_col_val2)';
61
+		 $builtQuery = (string) $queryBuilder;
62 62
 
63
-         $this->assertEquals($expectedQuery, $builtQuery);
64
-     }
63
+		 $this->assertEquals($expectedQuery, $builtQuery);
64
+	 }
65 65
  }
Please login to merge, or discard this patch.
tests/Core/Database/Abstraction/QueryBuilderTest.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@
 block discarded – undo
11 11
 use EmmetBlue\Core\Database\Abstraction\QueryBuilder;
12 12
 
13 13
 /**
14
-  * class QueryBuilderTest.
15
-  *
16
-  * @author Samuel Adeshina <[email protected]>
17
-  *
18
-  * @since v0.0.1 27/05/2016 14:27
19
-  */
14
+ * class QueryBuilderTest.
15
+ *
16
+ * @author Samuel Adeshina <[email protected]>
17
+ *
18
+ * @since v0.0.1 27/05/2016 14:27
19
+ */
20 20
  class QueryBuilderTest extends \PHPUnit_Framework_TestCase
21 21
  {
22
-     public function testBuilderActuallyBuilding()
23
-     {
24
-         $queryBuilder = new QueryBuilder('INSERT INTO tbl_name');
25
-         $queryBuilder = $queryBuilder->build("VALUES ('tbl_col1', 'tbl_col2')");
22
+	 public function testBuilderActuallyBuilding()
23
+	 {
24
+		 $queryBuilder = new QueryBuilder('INSERT INTO tbl_name');
25
+		 $queryBuilder = $queryBuilder->build("VALUES ('tbl_col1', 'tbl_col2')");
26 26
 
27
-         $builtQuery = (string) $queryBuilder;
28
-         $expectedQuery = "INSERT INTO tbl_name VALUES ('tbl_col1', 'tbl_col2')";
27
+		 $builtQuery = (string) $queryBuilder;
28
+		 $expectedQuery = "INSERT INTO tbl_name VALUES ('tbl_col1', 'tbl_col2')";
29 29
 
30
-         $this->assertEquals($expectedQuery, $builtQuery);
31
-     }
30
+		 $this->assertEquals($expectedQuery, $builtQuery);
31
+	 }
32 32
 
33
-     public function testWrapStringFunctionBehavesStatically()
34
-     {
35
-         $built = QueryBuilder::wrapString('Name', "'");
36
-     }
33
+	 public function testWrapStringFunctionBehavesStatically()
34
+	 {
35
+		 $built = QueryBuilder::wrapString('Name', "'");
36
+	 }
37 37
  }
Please login to merge, or discard this patch.
src/Core/Builder/BuilderFactory.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     /**
40 40
      * Returns a new instance of the requested builder object
41 41
      *
42
-     * @return EmmetBlue\Core\Database\Builder\BuildableInterface
42
+     * @return BuildableInterface
43 43
      */
44 44
     public function getBuilder() : BuildableInterface
45 45
     {
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,36 +13,36 @@
 block discarded – undo
13 13
  */
14 14
 class BuilderFactory
15 15
 {
16
-    /**
17
-     * @var string
18
-     */
19
-    protected $builder;
16
+	/**
17
+	 * @var string
18
+	 */
19
+	protected $builder;
20 20
 
21
-    /**
22
-     * @param string $builder
23
-     * @param string $builderType
24
-     * @throws \Exception
25
-     */
26
-    public function __construct(string $builder, string $builderType)
27
-    {
28
-        $builder = __NAMESPACE__."\\$builder\\$builderType$builder";
29
-        $builder = new $builder;
21
+	/**
22
+	 * @param string $builder
23
+	 * @param string $builderType
24
+	 * @throws \Exception
25
+	 */
26
+	public function __construct(string $builder, string $builderType)
27
+	{
28
+		$builder = __NAMESPACE__."\\$builder\\$builderType$builder";
29
+		$builder = new $builder;
30 30
 
31
-        if (!($builder instanceof BuildableInterface))
32
-        {
33
-            throw new \Exception();
34
-        }
31
+		if (!($builder instanceof BuildableInterface))
32
+		{
33
+			throw new \Exception();
34
+		}
35 35
 
36
-        $this->builder = $builder;
37
-    }
36
+		$this->builder = $builder;
37
+	}
38 38
 
39
-    /**
40
-     * Returns a new instance of the requested builder object
41
-     *
42
-     * @return EmmetBlue\Core\Database\Builder\BuildableInterface
43
-     */
44
-    public function getBuilder() : BuildableInterface
45
-    {
46
-        return $this->builder;
47
-    }
39
+	/**
40
+	 * Returns a new instance of the requested builder object
41
+	 *
42
+	 * @return EmmetBlue\Core\Database\Builder\BuildableInterface
43
+	 */
44
+	public function getBuilder() : BuildableInterface
45
+	{
46
+		return $this->builder;
47
+	}
48 48
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types=1);
1
+<?php declare (strict_types = 1);
2 2
 /**
3 3
  * @license MIT
4 4
  * @author Samuel Adeshina <[email protected]>
Please login to merge, or discard this patch.
src/Core/Builder/QueryBuilder/DeleteQueryBuilder.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,6 @@  discard block
 block discarded – undo
23 23
     protected $queryBuilder;
24 24
 
25 25
     /**
26
-     * @param string|null $tableName
27 26
      */
28 27
     public function __construct()
29 28
     {
@@ -36,7 +35,7 @@  discard block
 block discarded – undo
36 35
      *
37 36
      * @param string $tableName
38 37
      *
39
-     * @return \EmmetBlue\Core\Builder\DeleteQueryBuilder
38
+     * @return DeleteQueryBuilder
40 39
      */
41 40
     public function from(string $tableName)
42 41
     {
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
  */
18 18
 class DeleteQueryBuilder extends QueryBuilder
19 19
 {
20
-    /**
21
-     * @var \EmmetBlue\Core\Builder\QueryBuilder
22
-     */
23
-    protected $queryBuilder;
20
+	/**
21
+	 * @var \EmmetBlue\Core\Builder\QueryBuilder
22
+	 */
23
+	protected $queryBuilder;
24 24
 
25
-    /**
26
-     * @param string|null $tableName
27
-     */
28
-    public function __construct()
29
-    {
30
-        $DeleteKeyword = "Delete";
31
-        $this->queryBuilder = $this->build($DeleteKeyword);
32
-    }
25
+	/**
26
+	 * @param string|null $tableName
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$DeleteKeyword = "Delete";
31
+		$this->queryBuilder = $this->build($DeleteKeyword);
32
+	}
33 33
 
34
-     /**
35
-     * {@inheritdoc}
36
-     *
37
-     * @param string $tableName
38
-     *
39
-     * @return \EmmetBlue\Core\Builder\DeleteQueryBuilder
40
-     */
41
-    public function from(string $tableName)
42
-    {
43
-        $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName);
34
+	 /**
35
+	  * {@inheritdoc}
36
+	  *
37
+	  * @param string $tableName
38
+	  *
39
+	  * @return \EmmetBlue\Core\Builder\DeleteQueryBuilder
40
+	  */
41
+	public function from(string $tableName)
42
+	{
43
+		$this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName);
44 44
 
45
-        return $this;
46
-    }
45
+		return $this;
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types=1);
1
+<?php declare (strict_types = 1);
2 2
 /**
3 3
  * @license MIT
4 4
  * @author Samuel Adeshina <[email protected]>
Please login to merge, or discard this patch.
src/Core/Builder/QueryBuilder/InsertQueryBuilder.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * @param string[] $tableColumns Optional, provide this to specify the
39 39
      *                               columns that should be acted on
40 40
      *
41
-     * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder
41
+     * @return InsertQueryBuilder
42 42
      */
43 43
     public function into(string $tableName, array $tableColumns = [])
44 44
     {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @param string[] $inputValues
60 60
      *
61
-     * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder
61
+     * @return InsertQueryBuilder
62 62
      */
63 63
     public function values(array $inputValues)
64 64
     {
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -17,68 +17,68 @@
 block discarded – undo
17 17
  */
18 18
 class InsertQueryBuilder extends QueryBuilder
19 19
 {
20
-    /**
21
-     * @var \EmmetBlue\Core\Abstraction\QueryBuilder
22
-     */
23
-    protected $queryBuilder;
20
+	/**
21
+	 * @var \EmmetBlue\Core\Abstraction\QueryBuilder
22
+	 */
23
+	protected $queryBuilder;
24 24
 
25
-    /**
26
-     * @param string|null $tableName
27
-     */
28
-    public function __construct(string $tableName = null)
29
-    {
30
-        $insertKeyword = (is_null($tableName)) ? 'INSERT' : 'INSERT INTO '.$tableName;
31
-        $this->queryBuilder = $this->build($insertKeyword);
32
-    }
25
+	/**
26
+	 * @param string|null $tableName
27
+	 */
28
+	public function __construct(string $tableName = null)
29
+	{
30
+		$insertKeyword = (is_null($tableName)) ? 'INSERT' : 'INSERT INTO '.$tableName;
31
+		$this->queryBuilder = $this->build($insertKeyword);
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     *
37
-     * @param string   $tableName
38
-     * @param string[] $tableColumns Optional, provide this to specify the
39
-     *                               columns that should be acted on
40
-     *
41
-     * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder
42
-     */
43
-    public function into(string $tableName, array $tableColumns = [])
44
-    {
45
-        $intoKeyword = 'INTO '.$tableName;
34
+	/**
35
+	 * {@inheritdoc}
36
+	 *
37
+	 * @param string   $tableName
38
+	 * @param string[] $tableColumns Optional, provide this to specify the
39
+	 *                               columns that should be acted on
40
+	 *
41
+	 * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder
42
+	 */
43
+	public function into(string $tableName, array $tableColumns = [])
44
+	{
45
+		$intoKeyword = 'INTO '.$tableName;
46 46
 
47
-        if (!empty($tableColumns)) {
48
-            $intoKeyword .= $this->wrapString(self::getImplodedString($tableColumns), '(', ')');
49
-        }
47
+		if (!empty($tableColumns)) {
48
+			$intoKeyword .= $this->wrapString(self::getImplodedString($tableColumns), '(', ')');
49
+		}
50 50
 
51
-        $this->queryBuilder = $this->queryBuilder->build($intoKeyword);
51
+		$this->queryBuilder = $this->queryBuilder->build($intoKeyword);
52 52
 
53
-        return $this;
54
-    }
53
+		return $this;
54
+	}
55 55
 
56
-    /**
57
-     * {@inheritdoc}
58
-     *
59
-     * @param string[] $inputValues
60
-     *
61
-     * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder
62
-     */
63
-    public function values(array $inputValues)
64
-    {
65
-        $valuesKeyword = 'VALUES ';
66
-        $isMultidimentional = is_array($inputValues[0]);
56
+	/**
57
+	 * {@inheritdoc}
58
+	 *
59
+	 * @param string[] $inputValues
60
+	 *
61
+	 * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder
62
+	 */
63
+	public function values(array $inputValues)
64
+	{
65
+		$valuesKeyword = 'VALUES ';
66
+		$isMultidimentional = is_array($inputValues[0]);
67 67
 
68
-        if (!$isMultidimentional) {
69
-            $valuesKeyword .= $this->wrapString(self::getImplodedString($inputValues), '(', ')');
70
-        } else {
71
-            $tempValuesKeywords = [];
72
-            foreach ($inputValues as $inputValue) {
73
-                $tempValuesKeywords[] = $this->wrapString(self::getImplodedString($inputValue), '(', ')');
74
-            }
68
+		if (!$isMultidimentional) {
69
+			$valuesKeyword .= $this->wrapString(self::getImplodedString($inputValues), '(', ')');
70
+		} else {
71
+			$tempValuesKeywords = [];
72
+			foreach ($inputValues as $inputValue) {
73
+				$tempValuesKeywords[] = $this->wrapString(self::getImplodedString($inputValue), '(', ')');
74
+			}
75 75
 
76
-            $valuesKeyword .= self::getImplodedString($tempValuesKeywords);
77
-            unset($tempValuesKeywords);
78
-        }
76
+			$valuesKeyword .= self::getImplodedString($tempValuesKeywords);
77
+			unset($tempValuesKeywords);
78
+		}
79 79
 
80
-        $this->queryBuilder = $this->queryBuilder->build($valuesKeyword);
80
+		$this->queryBuilder = $this->queryBuilder->build($valuesKeyword);
81 81
 
82
-        return $this;
83
-    }
82
+		return $this;
83
+	}
84 84
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types=1);
1
+<?php declare (strict_types = 1);
2 2
 /**
3 3
  * @license MIT
4 4
  * @author Samuel Adeshina <[email protected]>
Please login to merge, or discard this patch.
src/Core/Builder/QueryBuilder/QueryBuilder.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
     /**
108 108
      * Implodes an array into a string while keeping track of the keys.
109 109
      *
110
-     * @param array  $arrayToImplode
110
+     * @param string[]  $arrayToImplode
111 111
      * @param string $delimiter Optional.
112 112
      *
113 113
      * @return string
Please login to merge, or discard this patch.
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -20,169 +20,169 @@
 block discarded – undo
20 20
  */
21 21
 class QueryBuilder implements BuildableInterface
22 22
 {
23
-    /**
24
-     * @var string Global Sql Statement
25
-     */
26
-    private $sqlStatement;
27
-
28
-    /**
29
-     * @var string SPACE
30
-     */
31
-    const SPACE = ' ';
32
-
33
-    /**
34
-     * @param string | null $sqlStatement SQL Statement to be processed by the build method
35
-     *
36
-     * @throws {@todo Write exception class}
37
-     */
38
-    public function __construct(string $sqlStatement = null)
39
-    {
40
-        self::setSqlStatement($sqlStatement);
41
-    }
42
-
43
-    /**
44
-     * Returns the string value of the global sqlStatement variable.
45
-     *
46
-     * @return string
47
-     */
48
-    private function getSqlStatement()
49
-    {
50
-        return $this->sqlStatement;
51
-    }
52
-
53
-    /**
54
-     * Sets/Modifies the value of the global sqlStatement variable.
55
-     *
56
-     * @param string $sqlStatement to set/replace global equivalent to.
57
-     *
58
-     * @return null
59
-     */
60
-    private function setSqlStatement(string $sqlStatement = null)
61
-    {
62
-        $this->sqlStatement = $sqlStatement;
63
-    }
64
-
65
-    /**
66
-     * Builds a QueryBuilder object.
67
-     * {@see QueryBuildableInterface}.
68
-     *
69
-     * @param string | null $sqlStringToAppend
70
-     *
71
-     * @throws {@todo Create exceptions}
72
-     *
73
-     * @return QueryBuilder new instance of the QueryBuilder object.
74
-     */
75
-    public function build(string $sqlStringToAppend) : BuildableInterface
76
-    {
77
-        $separator = (empty(self::getSqlStatement())) ? '' : self::SPACE;
78
-        $newSqlString = self::getSqlStatement().$separator.$sqlStringToAppend;
79
-        self::setSqlStatement($newSqlString);
80
-
81
-        return $this;
82
-    }
83
-
84
-    /**
85
-     * returns a `built sql` when the QueryBuilder object is casted to a string.
86
-     *
87
-     * @return string
88
-     */
89
-    public function __toString()
90
-    {
91
-        return self::getSqlStatement();
92
-    }
93
-
94
-    /**
95
-     * Implodes an array into a string.
96
-     *
97
-     * @param array  $arrayToImplode
98
-     * @param string $delimiter      Optional.
99
-     *
100
-     * @return string
101
-     */
102
-    protected function getImplodedString(array $arrayToImplode, string $delimiter = ',') : string
103
-    {
104
-        return implode($delimiter, $arrayToImplode);
105
-    }
106
-
107
-    /**
108
-     * Implodes an array into a string while keeping track of the keys.
109
-     *
110
-     * @param array  $arrayToImplode
111
-     * @param string $delimiter Optional.
112
-     *
113
-     * @return string
114
-     */
115
-    protected function getImplodedStringWithKeys(array $arrayToImplode, string $keyDelimiter='=', string $delimiter = ',') : string
116
-    {
117
-        $implodedStrings = []; 
118
-
119
-        foreach ($arrayToImplode as $key=>$value)
120
-        {
121
-            $implodedStrings[] = $key.$keyDelimiter.$value;
122
-        }
123
-
124
-        return implode($delimiter, $implodedStrings);
125
-    }
126
-
127
-    /**
128
-     * Wraps a string with specified characters.
129
-     *
130
-     * @param string      $strBefore
131
-     * @param string|null $strAfter
132
-     * @param string      $strToWrap
133
-     *
134
-     * @return string
135
-     */
136
-    public static function wrapString(string $strToWrap, string $strBefore, string $strAfter = null) : string
137
-    {
138
-        return $strBefore.$strToWrap.(is_null($strAfter) ? $strBefore : $strAfter);
139
-    }
140
-
141
-    /**
142
-     * {@inheritdoc}
143
-     *
144
-     * @param string $condition
145
-     *
146
-     * @return \EmmetBlue\Core\Builder\BuildableInterface
147
-     */
148
-    public function where(string $condition)
149
-    {
150
-        $whereString = "WHERE $condition";
151
-
152
-        $this->queryBuilder = $this->queryBuilder->build($whereString);
153
-
154
-        return $this;
155
-    }
156
-
157
-    /**
158
-     * {@inheritdoc}
159
-     *
160
-     * @param string $condition
161
-     *
162
-     * @return \EmmetBlue\Core\Builder\BuildableInterface
163
-     */
164
-    public function andWhere(string $condition)
165
-    {
166
-         $whereString = "AND WHERE $condition";
167
-
168
-        $this->queryBuilder = $this->queryBuilder->build($whereString);
169
-
170
-        return $this;
171
-    }
172
-
173
-    /**
174
-     * {@inheritdoc}
175
-     *
176
-     * @param string $condition
177
-     *
178
-     * @return \EmmetBlue\Core\Builder\BuildableInterface
179
-     */
180
-    public function orWhere(string $condition)
181
-    {
182
-         $whereString = "OR WHERE $condition";
183
-
184
-        $this->queryBuilder = $this->queryBuilder->build($whereString);
185
-
186
-        return $this;
187
-    }
23
+	/**
24
+	 * @var string Global Sql Statement
25
+	 */
26
+	private $sqlStatement;
27
+
28
+	/**
29
+	 * @var string SPACE
30
+	 */
31
+	const SPACE = ' ';
32
+
33
+	/**
34
+	 * @param string | null $sqlStatement SQL Statement to be processed by the build method
35
+	 *
36
+	 * @throws {@todo Write exception class}
37
+	 */
38
+	public function __construct(string $sqlStatement = null)
39
+	{
40
+		self::setSqlStatement($sqlStatement);
41
+	}
42
+
43
+	/**
44
+	 * Returns the string value of the global sqlStatement variable.
45
+	 *
46
+	 * @return string
47
+	 */
48
+	private function getSqlStatement()
49
+	{
50
+		return $this->sqlStatement;
51
+	}
52
+
53
+	/**
54
+	 * Sets/Modifies the value of the global sqlStatement variable.
55
+	 *
56
+	 * @param string $sqlStatement to set/replace global equivalent to.
57
+	 *
58
+	 * @return null
59
+	 */
60
+	private function setSqlStatement(string $sqlStatement = null)
61
+	{
62
+		$this->sqlStatement = $sqlStatement;
63
+	}
64
+
65
+	/**
66
+	 * Builds a QueryBuilder object.
67
+	 * {@see QueryBuildableInterface}.
68
+	 *
69
+	 * @param string | null $sqlStringToAppend
70
+	 *
71
+	 * @throws {@todo Create exceptions}
72
+	 *
73
+	 * @return QueryBuilder new instance of the QueryBuilder object.
74
+	 */
75
+	public function build(string $sqlStringToAppend) : BuildableInterface
76
+	{
77
+		$separator = (empty(self::getSqlStatement())) ? '' : self::SPACE;
78
+		$newSqlString = self::getSqlStatement().$separator.$sqlStringToAppend;
79
+		self::setSqlStatement($newSqlString);
80
+
81
+		return $this;
82
+	}
83
+
84
+	/**
85
+	 * returns a `built sql` when the QueryBuilder object is casted to a string.
86
+	 *
87
+	 * @return string
88
+	 */
89
+	public function __toString()
90
+	{
91
+		return self::getSqlStatement();
92
+	}
93
+
94
+	/**
95
+	 * Implodes an array into a string.
96
+	 *
97
+	 * @param array  $arrayToImplode
98
+	 * @param string $delimiter      Optional.
99
+	 *
100
+	 * @return string
101
+	 */
102
+	protected function getImplodedString(array $arrayToImplode, string $delimiter = ',') : string
103
+	{
104
+		return implode($delimiter, $arrayToImplode);
105
+	}
106
+
107
+	/**
108
+	 * Implodes an array into a string while keeping track of the keys.
109
+	 *
110
+	 * @param array  $arrayToImplode
111
+	 * @param string $delimiter Optional.
112
+	 *
113
+	 * @return string
114
+	 */
115
+	protected function getImplodedStringWithKeys(array $arrayToImplode, string $keyDelimiter='=', string $delimiter = ',') : string
116
+	{
117
+		$implodedStrings = []; 
118
+
119
+		foreach ($arrayToImplode as $key=>$value)
120
+		{
121
+			$implodedStrings[] = $key.$keyDelimiter.$value;
122
+		}
123
+
124
+		return implode($delimiter, $implodedStrings);
125
+	}
126
+
127
+	/**
128
+	 * Wraps a string with specified characters.
129
+	 *
130
+	 * @param string      $strBefore
131
+	 * @param string|null $strAfter
132
+	 * @param string      $strToWrap
133
+	 *
134
+	 * @return string
135
+	 */
136
+	public static function wrapString(string $strToWrap, string $strBefore, string $strAfter = null) : string
137
+	{
138
+		return $strBefore.$strToWrap.(is_null($strAfter) ? $strBefore : $strAfter);
139
+	}
140
+
141
+	/**
142
+	 * {@inheritdoc}
143
+	 *
144
+	 * @param string $condition
145
+	 *
146
+	 * @return \EmmetBlue\Core\Builder\BuildableInterface
147
+	 */
148
+	public function where(string $condition)
149
+	{
150
+		$whereString = "WHERE $condition";
151
+
152
+		$this->queryBuilder = $this->queryBuilder->build($whereString);
153
+
154
+		return $this;
155
+	}
156
+
157
+	/**
158
+	 * {@inheritdoc}
159
+	 *
160
+	 * @param string $condition
161
+	 *
162
+	 * @return \EmmetBlue\Core\Builder\BuildableInterface
163
+	 */
164
+	public function andWhere(string $condition)
165
+	{
166
+		 $whereString = "AND WHERE $condition";
167
+
168
+		$this->queryBuilder = $this->queryBuilder->build($whereString);
169
+
170
+		return $this;
171
+	}
172
+
173
+	/**
174
+	 * {@inheritdoc}
175
+	 *
176
+	 * @param string $condition
177
+	 *
178
+	 * @return \EmmetBlue\Core\Builder\BuildableInterface
179
+	 */
180
+	public function orWhere(string $condition)
181
+	{
182
+		 $whereString = "OR WHERE $condition";
183
+
184
+		$this->queryBuilder = $this->queryBuilder->build($whereString);
185
+
186
+		return $this;
187
+	}
188 188
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 /**
4 4
  * @license MIT
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return string
114 114
      */
115
-    protected function getImplodedStringWithKeys(array $arrayToImplode, string $keyDelimiter='=', string $delimiter = ',') : string
115
+    protected function getImplodedStringWithKeys(array $arrayToImplode, string $keyDelimiter = '=', string $delimiter = ',') : string
116 116
     {
117 117
         $implodedStrings = []; 
118 118
 
Please login to merge, or discard this patch.
src/Core/Builder/QueryBuilder/SelectQueryBuilder.php 3 patches
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,6 @@  discard block
 block discarded – undo
23 23
     protected $queryBuilder;
24 24
 
25 25
     /**
26
-     * @param string|null $tableName
27 26
      */
28 27
     public function __construct()
29 28
     {
@@ -36,7 +35,7 @@  discard block
 block discarded – undo
36 35
      *
37 36
      * @param int $topValue
38 37
      *
39
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
38
+     * @return SelectQueryBuilder
40 39
      */
41 40
     public function top(int $topValue)
42 41
     {
@@ -48,9 +47,9 @@  discard block
 block discarded – undo
48 47
     /**
49 48
      * {@inheritdoc}
50 49
      *
51
-     * @param string $columns
50
+     * @param string[] $columns
52 51
      *
53
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
52
+     * @return SelectQueryBuilder
54 53
      */
55 54
     public function columns(string ...$columns)
56 55
     {
@@ -64,7 +63,7 @@  discard block
 block discarded – undo
64 63
      *
65 64
      * @param string $tableName
66 65
      *
67
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
66
+     * @return SelectQueryBuilder
68 67
      */
69 68
     public function from(string $tableName)
70 69
     {
@@ -79,7 +78,7 @@  discard block
 block discarded – undo
79 78
      * @param string $tableName
80 79
      * @param string $condition
81 80
      *
82
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
81
+     * @return SelectQueryBuilder
83 82
      */
84 83
     public function innerJoin(string $tableName, string $condition)
85 84
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types=1);
1
+<?php declare (strict_types = 1);
2 2
 /**
3 3
  * @license MIT
4 4
  * @author Samuel Adeshina <[email protected]>
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -17,84 +17,84 @@
 block discarded – undo
17 17
  */
18 18
 class SelectQueryBuilder extends QueryBuilder
19 19
 {
20
-    /**
21
-     * @var \EmmetBlue\Core\Builder\QueryBuilder
22
-     */
23
-    protected $queryBuilder;
20
+	/**
21
+	 * @var \EmmetBlue\Core\Builder\QueryBuilder
22
+	 */
23
+	protected $queryBuilder;
24 24
 
25
-    /**
26
-     * @param string|null $tableName
27
-     */
28
-    public function __construct()
29
-    {
30
-        $SelectKeyword = "SELECT";
31
-        $this->queryBuilder = $this->build($SelectKeyword);
32
-    }
25
+	/**
26
+	 * @param string|null $tableName
27
+	 */
28
+	public function __construct()
29
+	{
30
+		$SelectKeyword = "SELECT";
31
+		$this->queryBuilder = $this->build($SelectKeyword);
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     *
37
-     * @param int $topValue
38
-     *
39
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
40
-     */
41
-    public function top(int $topValue)
42
-    {
43
-        $this->queryBuilder = $this->queryBuilder->build("TOP ".$topValue);
34
+	/**
35
+	 * {@inheritdoc}
36
+	 *
37
+	 * @param int $topValue
38
+	 *
39
+	 * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
40
+	 */
41
+	public function top(int $topValue)
42
+	{
43
+		$this->queryBuilder = $this->queryBuilder->build("TOP ".$topValue);
44 44
 
45
-        return $this;
46
-    }
47
-    /**
48
-    * This method handles situations that requires to
49
-    * select all from the table.
50
-    * @param *
51
-    */
52
-    public function all()
53
-    {
54
-        $this->queryBuilder = $this->queryBuilder->build("*");
55
-        return $this;
56
-    }
57
-    /**
58
-     * {@inheritdoc}
59
-     *
60
-     * @param string $columns
61
-     *
62
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
63
-     */
64
-    public function columns(string ...$columns)
65
-    {
66
-        $this->queryBuilder = $this->queryBuilder->build(self::getImplodedString($columns));
45
+		return $this;
46
+	}
47
+	/**
48
+	 * This method handles situations that requires to
49
+	 * select all from the table.
50
+	 * @param *
51
+	 */
52
+	public function all()
53
+	{
54
+		$this->queryBuilder = $this->queryBuilder->build("*");
55
+		return $this;
56
+	}
57
+	/**
58
+	 * {@inheritdoc}
59
+	 *
60
+	 * @param string $columns
61
+	 *
62
+	 * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
63
+	 */
64
+	public function columns(string ...$columns)
65
+	{
66
+		$this->queryBuilder = $this->queryBuilder->build(self::getImplodedString($columns));
67 67
 
68
-        return $this;
69
-    }
68
+		return $this;
69
+	}
70 70
 
71
-     /**
72
-     * {@inheritdoc}
73
-     *
74
-     * @param string $tableName
75
-     *
76
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
77
-     */
78
-    public function from(string $tableName)
79
-    {
80
-        $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName);
71
+	 /**
72
+	  * {@inheritdoc}
73
+	  *
74
+	  * @param string $tableName
75
+	  *
76
+	  * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
77
+	  */
78
+	public function from(string $tableName)
79
+	{
80
+		$this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName);
81 81
 
82
-        return $this;
83
-    }
82
+		return $this;
83
+	}
84 84
 
85
-    /**
86
-     * {@inheritdoc}
87
-     *
88
-     * @param string $tableName
89
-     * @param string $condition
90
-     *
91
-     * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
92
-     */
93
-    public function innerJoin(string $tableName, string $condition)
94
-    {
95
-        $string = "INNER JOIN ".$tableName." ON ".$condition;
96
-        $this->queryBuilder = $this->queryBuilder->build($string);
85
+	/**
86
+	 * {@inheritdoc}
87
+	 *
88
+	 * @param string $tableName
89
+	 * @param string $condition
90
+	 *
91
+	 * @return \EmmetBlue\Core\Builder\SelectQueryBuilder
92
+	 */
93
+	public function innerJoin(string $tableName, string $condition)
94
+	{
95
+		$string = "INNER JOIN ".$tableName." ON ".$condition;
96
+		$this->queryBuilder = $this->queryBuilder->build($string);
97 97
 
98
-        return $this;
99
-    }
98
+		return $this;
99
+	}
100 100
 }
Please login to merge, or discard this patch.
src/Core/Builder/QueryBuilder/UpdateQueryBuilder.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      *
37 37
      * @param string $tableName
38 38
      *
39
-     * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder
39
+     * @return UpdateQueryBuilder
40 40
      */
41 41
     public function table(string $tableName)
42 42
     {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @param string[] $inputValues
52 52
      *
53
-     * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder
53
+     * @return UpdateQueryBuilder
54 54
      */
55 55
     public function set(array $inputValues)
56 56
     {
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -17,49 +17,49 @@
 block discarded – undo
17 17
  */
18 18
 class UpdateQueryBuilder extends QueryBuilder
19 19
 {
20
-    /**
21
-     * @var \EmmetBlue\Core\Builder\QueryBuilder
22
-     */
23
-    protected $queryBuilder;
20
+	/**
21
+	 * @var \EmmetBlue\Core\Builder\QueryBuilder
22
+	 */
23
+	protected $queryBuilder;
24 24
 
25
-    /**
26
-     * @param string|null $tableName
27
-     */
28
-    public function __construct(string $tableName = null)
29
-    {
30
-        $updateKeyword = (is_null($tableName)) ? 'UPDATE' : 'UPDATE '.$tableName;
31
-        $this->queryBuilder = $this->build($updateKeyword);
32
-    }
25
+	/**
26
+	 * @param string|null $tableName
27
+	 */
28
+	public function __construct(string $tableName = null)
29
+	{
30
+		$updateKeyword = (is_null($tableName)) ? 'UPDATE' : 'UPDATE '.$tableName;
31
+		$this->queryBuilder = $this->build($updateKeyword);
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     *
37
-     * @param string $tableName
38
-     *
39
-     * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder
40
-     */
41
-    public function table(string $tableName)
42
-    {
43
-        $this->queryBuilder = $this->queryBuilder->build($tableName);
34
+	/**
35
+	 * {@inheritdoc}
36
+	 *
37
+	 * @param string $tableName
38
+	 *
39
+	 * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder
40
+	 */
41
+	public function table(string $tableName)
42
+	{
43
+		$this->queryBuilder = $this->queryBuilder->build($tableName);
44 44
 
45
-        return $this;
46
-    }
45
+		return $this;
46
+	}
47 47
 
48
-    /**
49
-     * {@inheritdoc}
50
-     *
51
-     * @param string[] $inputValues
52
-     *
53
-     * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder
54
-     */
55
-    public function set(array $inputValues)
56
-    {
57
-        $valuesKeyword = 'SET ';
48
+	/**
49
+	 * {@inheritdoc}
50
+	 *
51
+	 * @param string[] $inputValues
52
+	 *
53
+	 * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder
54
+	 */
55
+	public function set(array $inputValues)
56
+	{
57
+		$valuesKeyword = 'SET ';
58 58
 
59
-        $valuesKeyword .= self::getImplodedStringWithKeys($inputValues);
59
+		$valuesKeyword .= self::getImplodedStringWithKeys($inputValues);
60 60
 
61
-        $this->queryBuilder = $this->queryBuilder->build($valuesKeyword);
61
+		$this->queryBuilder = $this->queryBuilder->build($valuesKeyword);
62 62
 
63
-        return $this;
64
-    }
63
+		return $this;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare (strict_types=1);
1
+<?php declare (strict_types = 1);
2 2
 /**
3 3
  * @license MIT
4 4
  * @author Samuel Adeshina <[email protected]>
Please login to merge, or discard this patch.
src/Core/Logger/ErrorLog.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,6 @@
 block discarded – undo
11 11
 use EmmetBlue\Core\Builder\BuilderFactory as Builder;
12 12
 use EmmetBlue\Core\Factory\DatabaseConnectionFactory as DBConnectionFactory;
13 13
 use EmmetBlue\Core\Builder\QueryBuilder\QueryBuilder as QB;
14
-use EmmetBlue\Core\Exception\SQLException;
15 14
 /**
16 15
  * Class ErrorLog
17 16
  *
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class ErrorLog implements LogInterface
24 24
 {
25
-    public static function log(int $databaseUserId, string $errorNumber, string $errorSeverity, string $errorMessage, string $errorObject=null)
26
-    {
27
-        /**
28
-         * For now I am not doing anything with $errorObject yet.
29
-         *
30
-         * As soon as it can be properly serialized for the MSSQL Server db
31
-         * it shall be saved in the database.
32
-         *
33
-         * FUNNY: I'M GONNA INTENTIONALLY LEAVE THIS COMMIT FOR MY AMUSEMENT
34
-         * $errorObject, wasn't the issue. My DB schema was.
35
-         */
36
-        $insertBuilder = (new Builder("QueryBuilder", "Insert"))->getBuilder();
25
+	public static function log(int $databaseUserId, string $errorNumber, string $errorSeverity, string $errorMessage, string $errorObject=null)
26
+	{
27
+		/**
28
+		 * For now I am not doing anything with $errorObject yet.
29
+		 *
30
+		 * As soon as it can be properly serialized for the MSSQL Server db
31
+		 * it shall be saved in the database.
32
+		 *
33
+		 * FUNNY: I'M GONNA INTENTIONALLY LEAVE THIS COMMIT FOR MY AMUSEMENT
34
+		 * $errorObject, wasn't the issue. My DB schema was.
35
+		 */
36
+		$insertBuilder = (new Builder("QueryBuilder", "Insert"))->getBuilder();
37 37
 
38
-        $insertBuilder
39
-            ->into('
38
+		$insertBuilder
39
+			->into('
40 40
                 [Logs].[ErrorLog]
41 41
                 (
42 42
                     ErrorTime,
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
                     ErrorMessage
47 47
                 )
48 48
             ')
49
-            ->values([
50
-                'GETDATE()',
51
-                $databaseUserId,
52
-                QB::wrapString($errorNumber, "'"),
53
-                QB::wrapString($errorSeverity, "'"),
54
-                QB::wrapString($errorMessage, "'")
55
-            ]);
49
+			->values([
50
+				'GETDATE()',
51
+				$databaseUserId,
52
+				QB::wrapString($errorNumber, "'"),
53
+				QB::wrapString($errorSeverity, "'"),
54
+				QB::wrapString($errorMessage, "'")
55
+			]);
56 56
             
57
-        DBConnectionFactory::getConnection()->query((string)$insertBuilder);
58
-    }
57
+		DBConnectionFactory::getConnection()->query((string)$insertBuilder);
58
+	}
59 59
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare (strict_types=1);
1
+<?php declare (strict_types = 1);
2 2
 /**
3 3
  * @license MIT
4 4
  * @author Samuel Adeshina <[email protected]>
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class ErrorLog implements LogInterface
24 24
 {
25
-    public static function log(int $databaseUserId, string $errorNumber, string $errorSeverity, string $errorMessage, string $errorObject=null)
25
+    public static function log(int $databaseUserId, string $errorNumber, string $errorSeverity, string $errorMessage, string $errorObject = null)
26 26
     {
27 27
         /**
28 28
          * For now I am not doing anything with $errorObject yet.
@@ -54,6 +54,6 @@  discard block
 block discarded – undo
54 54
                 QB::wrapString($errorMessage, "'")
55 55
             ]);
56 56
             
57
-        DBConnectionFactory::getConnection()->query((string)$insertBuilder);
57
+        DBConnectionFactory::getConnection()->query((string) $insertBuilder);
58 58
     }
59 59
 }
Please login to merge, or discard this patch.