Skip to content

Commit 9e2deb5

Browse files
committed
Modyfied for php7
1 parent 61cbcdf commit 9e2deb5

File tree

9 files changed

+39
-45
lines changed

9 files changed

+39
-45
lines changed

SQLQuery.php

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,28 @@
3030
*
3131
* @example SELECT example1 FROM exampleTable WHERE example = {value->secureString}
3232
*
33-
* @author Rafal Przetakowski <[email protected]>
33+
* @author Rafal Przetakowski <[email protected]>
3434
*/
3535
class SQLQuery
3636
{
3737

3838
/**
3939
* SQL params
40+
*
4041
* @var array
4142
*/
4243
private $params = array();
4344

4445
/**
4546
* SQL query
47+
*
4648
* @var type
4749
*/
4850
private $sqlQuery;
4951

5052
/**
5153
* Directory where are SQL files
54+
*
5255
* @var string
5356
*/
5457
private $sqlDirectory = 'SQL/';
@@ -139,41 +142,31 @@ public function openFile($sqlFileName)
139142
/**
140143
*
141144
* @param string $parameterName
142-
* @param Mixed $parameterValue
145+
* @param Mixed $parameterValue
143146
*
144147
* @return null
145148
*/
146149
public function __set($parameterName, $parameterValue)
147150
{
148-
if (!isset($this->params[$parameterName])) {
151+
if (!isset($this->params[ $parameterName ])) {
149152
return null;
150153
}
151154

152155
if (is_array($parameterValue)) {
153-
$this->params[$parameterName]['value'] = $this->getImplodeArrayValue($parameterValue);
156+
$this->params[ $parameterName ]['value'] = $this->getImplodeArrayValue($parameterValue);
154157

155158
return;
156159
}
157160

158161
if (!is_object($parameterValue) && !$this->isEmptyParamType($parameterName)) {
159162
$parameterValue = $this->getObjectOfParameterValue($parameterName, $parameterValue);
160163
} else {
161-
$this->params[$parameterName]['value'] = is_numeric($parameterValue) ? $parameterValue : "'" . $parameterValue . "'";
164+
$this->params[ $parameterName ]['value'] = is_numeric($parameterValue) ? $parameterValue : "'" . $parameterValue . "'";
162165

163166
return;
164167
}
165168

166-
// list of string vartypes
167-
if ($parameterValue instanceof String ||
168-
$parameterValue instanceof Email ||
169-
$parameterValue instanceof Date ||
170-
$parameterValue instanceof SecureString ||
171-
$parameterValue instanceof Nip
172-
) {
173-
$this->params[$parameterName]['value'] = "'" . $parameterValue->val() . "'";
174-
} else {
175-
$this->params[$parameterName]['value'] = $parameterValue->val();
176-
}
169+
$this->params[ $parameterName ]['value'] = $parameterValue->val();
177170
}
178171

179172
/**
@@ -186,7 +179,7 @@ private function getImplodeArrayValue(array $arrayValue)
186179
{
187180
foreach ($arrayValue as $key => $value) {
188181
if (!is_numeric($value)) {
189-
$arrayValue[$key] = "'" . $value . "'";
182+
$arrayValue[ $key ] = "'" . $value . "'";
190183
}
191184
}
192185

@@ -201,7 +194,7 @@ private function getImplodeArrayValue(array $arrayValue)
201194
*/
202195
private function getParamType($parameterName)
203196
{
204-
return $this->params[$parameterName]['type'];
197+
return $this->params[ $parameterName ]['type'];
205198
}
206199

207200
/**
@@ -221,7 +214,7 @@ private function explodeQueryParams()
221214
$paramName = $paramArray[0];
222215
$paramType = (isset($paramArray[1]) ? $paramArray[1] : null);
223216

224-
$this->params[$paramName] = array("value" => null, "type" => $paramType);
217+
$this->params[ $paramName ] = array("value" => null, "type" => $paramType);
225218
}
226219
}
227220

@@ -240,7 +233,7 @@ private function isEmptyParamType($paramName)
240233

241234
/**
242235
*
243-
* @param type $parameterName
236+
* @param type $parameterName
244237
* @param paramType $parameterValue
245238
*
246239
* @return Object
@@ -253,7 +246,7 @@ private function getObjectOfParameterValue($parameterName, $parameterValue)
253246
if (empty($paramType)) {
254247
throw new \Exception("The parameter $parameterName is the wrong data type...");
255248
}
256-
$paramClass = 'Beeflow\SQLQueryManager\Vartypes\\' . ucfirst($paramType);
249+
$paramClass = 'Beeflow\SQLQueryManager\Vartypes\BF' . ucfirst($paramType);
257250
$parameterValue = new $paramClass($parameterValue);
258251
} catch (\Exception $e) {
259252
throw new \Exception("$parameterName field error: " . $e->getMessage());
@@ -277,29 +270,31 @@ private function parseConditions()
277270
$records = $matches[2];
278271

279272
foreach ($keys as $key => $value) {
280-
$rec[$value] = $records[$a];
273+
$rec[ $value ] = $records[ $a ];
281274
$a++;
282275
}
283276

284277
foreach ($this->params as $parameterName => $value) {
285-
if (isset($rec[$parameterName]) && !empty($value['value'])) {
286-
$sqlQuery = str_replace("{CON[{$parameterName}]:" . $rec[$parameterName] . ":CON}", $rec[$parameterName], str_replace(array("\n", "\r", "\t"), " ", $sqlQuery));
278+
if (isset($rec[ $parameterName ]) && !empty($value['value'])) {
279+
$sqlQuery = str_replace("{CON[{$parameterName}]:" . $rec[ $parameterName ] . ":CON}", $rec[ $parameterName ], str_replace(array("\n", "\r", "\t"), " ", $sqlQuery));
287280
}
288281
}
289282

290283
return $this->clearUnsetConditions($sqlQuery, $keys, $records);
291284
}
292285

293286
/**
287+
* @param string $sqlQuery
288+
* @param array $keys
289+
* @param array $records
294290
*
295-
* @param array $keys
296-
* @param array $records
291+
* @return mixed
297292
*/
298293
private function clearUnsetConditions($sqlQuery, $keys, $records)
299294
{
300295
$a = 0;
301296
foreach ($keys as $key => $value) {
302-
$sqlQuery = str_replace("{CON[{$value}]:" . $records[$a] . ":CON}", "", str_replace(array("\n", "\r", "\t"), " ", $sqlQuery));
297+
$sqlQuery = str_replace("{CON[{$value}]:" . $records[ $a ] . ":CON}", "", str_replace(array("\n", "\r", "\t"), " ", $sqlQuery));
303298
$a++;
304299
}
305300

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* @author Rafal Przetakowski <[email protected]>
2323
*/
24-
class Boolean
24+
class BFBoolean
2525
{
2626

2727
/**
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,22 @@
1818

1919
namespace Beeflow\SQLQueryManager\Vartypes;
2020

21-
use Beeflow\SQLQueryManager\Vartype\String;
21+
use Beeflow\SQLQueryManager\Vartype\BFString;
2222

2323
/**
2424
* @author Rafal Przetakowski <[email protected]>
2525
*/
26-
class Date extends DateTime
26+
class BFDate extends \DateTime
2727
{
2828

2929
private $dateTimeFormat = 'Y-m-d H:i:s';
3030
private $dateFormat = 'Y-m-d';
3131
private $timeZone = 'Europe/Warsaw';
3232

3333
/**
34+
* BFDate constructor.
3435
*
35-
* @param Mixed $val
36-
*
37-
* @throws Exception
36+
* @param string $time
3837
*/
3938
public function __construct($time)
4039
{
@@ -58,27 +57,27 @@ public function getDate()
5857

5958
/**
6059
*
61-
* @param string $dateTimeFormat {new string($dateTimeFormat)}
60+
* @param BFString $dateTimeFormat {new BFString($dateTimeFormat)}
6261
*/
63-
public function setDateTimeFormat(String $dateTimeFormat)
62+
public function setDateTimeFormat(BFString $dateTimeFormat)
6463
{
6564
$this->dateTimeFormat = $dateTimeFormat->val();
6665
}
6766

6867
/**
6968
*
70-
* @param string $dateFormat {new string($dateFormat)}
69+
* @param BFString $dateFormat {new BFString($dateFormat)}
7170
*/
72-
public function setDateFormat(String $dateFormat)
71+
public function setDateFormat(BFString $dateFormat)
7372
{
7473
$this->dateFormat = $dateFormat->val();
7574
}
7675

7776
/**
7877
*
79-
* @param string $timezone {new string($timezone)}
78+
* @param BFString $timezone {new BFString($timezone)}
8079
*/
81-
public function setTimezone(String $timezone)
80+
public function setTimezone(BFString $timezone)
8281
{
8382
parent::setTimezone($timezone->val());
8483
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* @author Rafal Przetakowski <[email protected]>
2323
*/
24-
class Double
24+
class BFDouble
2525
{
2626

2727
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* @author Rafal Przetakowski <[email protected]>
2323
*/
24-
class Email
24+
class BFEmail
2525
{
2626

2727
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* @author Rafal Przetakowski <[email protected]>
2323
*/
24-
class Float
24+
class BFFloat
2525
{
2626

2727
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* @author Rafal Przetakowski <[email protected]>
2323
*/
24-
class Integer
24+
class BFInteger
2525
{
2626

2727
/**

Vartypes/Nip.php renamed to Vartypes/BFNip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @author Rafal Przetakowski <[email protected]>
2727
*/
28-
class Nip
28+
class BFNip
2929
{
3030

3131
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* @author Rafal Przetakowski <[email protected]>
2323
*/
24-
class String {
24+
class BFString {
2525

2626
/**
2727
*

0 commit comments

Comments
 (0)