Passed
Push — master ( 5928a0...6c7f1e )
by dima
02:51
created
src/ISpecificationCriteria.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
     public function getWhereType();    
32 32
 
33
-    public function setWhere($field,$value = false);    
33
+    public function setWhere($field, $value = false);    
34 34
 
35 35
     public function setLimit($limit);
36 36
 
Please login to merge, or discard this patch.
src/AbstractEntity.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public function setId($id)
23 23
     {
24
-        if ($this->id !== null) {
24
+        if ($this->id!==null) {
25 25
             throw new BadMethodCallException(
26 26
                 "Идентификатор у сущности уже установлен");
27 27
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         return $this;		
35 35
     }
36 36
 	
37
-	public function setDeleted($deleted){
37
+	public function setDeleted($deleted) {
38 38
 		$this->deleted = $deleted;
39 39
 	}
40 40
 	
Please login to merge, or discard this patch.
src/Specification.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -73,12 +73,12 @@
 block discarded – undo
73 73
         return $this->whereType;
74 74
     }
75 75
 
76
-    function setWhere($field,$value = false)
76
+    function setWhere($field, $value = false)
77 77
     {
78
-        if($value!==false){
78
+        if ($value!==false) {
79 79
             $this->where[$field] = $value;
80 80
         }
81
-        else{
81
+        else {
82 82
             $this->where = $where;
83 83
         }
84 84
         
Please login to merge, or discard this patch.
src/QueryBuilderInterface.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
14 14
  */
15 15
 interface QueryBuilderInterface {
16 16
 	
17
-	public function getResultQuery($table,\SimpleORM\ISpecificationCriteria $Criteria);
17
+	public function getResultQuery($table, \SimpleORM\ISpecificationCriteria $Criteria);
18 18
 	
19
-	public function update($table,array $data,$where = []);
19
+	public function update($table, array $data, $where = []);
20 20
 
21
-	public function insert($table,array $data);
21
+	public function insert($table, array $data);
22 22
 	
23 23
 	public function insert_id();
24 24
 	
25
-	public function delete($table,$where = []);
25
+	public function delete($table, $where = []);
26 26
 }
Please login to merge, or discard this patch.
src/Adapter/CodeigniterQueryBuilder.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	protected function escape($str)
39 39
 	{
40 40
 		if (is_string($str)) {
41
-			$str = "'" . $this->escape_str($str) . "'";
41
+			$str = "'".$this->escape_str($str)."'";
42 42
 		} elseif (is_bool($str)) {
43
-			$str = ($str === FALSE) ? 0 : 1;
43
+			$str = ($str===FALSE) ? 0 : 1;
44 44
 		} elseif (is_null($str)) {
45 45
 			$str = 'NULL';
46 46
 		}
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		return $str;
49 49
 	}
50 50
 	
51
-	public function update($table,array $data,$where = []){
52
-		return $this->adapter->update($table,$data,$where);
51
+	public function update($table, array $data, $where = []) {
52
+		return $this->adapter->update($table, $data, $where);
53 53
 	}
54 54
 	
55
-	public function insert($table,array $data)
55
+	public function insert($table, array $data)
56 56
 	{
57
-		return $this->adapter->insert($table,$data);
57
+		return $this->adapter->insert($table, $data);
58 58
 	}
59 59
 	
60 60
 	public function insert_id()
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 		return $this->adapter->insert_id();
63 63
 	}
64 64
 
65
-	public function delete($table,$where = []){
66
-		return $this->adapter->delete($table,$where);
65
+	public function delete($table, $where = []) {
66
+		return $this->adapter->delete($table, $where);
67 67
 	}
68 68
 
69 69
 	protected function escape_str($str, $like = FALSE)
70 70
 	{
71 71
 
72
-		if(!$like){
72
+		if (!$like) {
73 73
 			return $this->adapter->escape_str($str);
74 74
 		}
75
-		else{
75
+		else {
76 76
 			return $this->adapter->escape_like_str($str);
77 77
 		}	
78 78
 		
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 			throw new HttpException('You cannot have an empty field name.');
112 112
 		}
113 113
 
114
-		if (strpos($field, '.') === false) {
115
-			return $this->TableName . '.' . $field;
114
+		if (strpos($field, '.')===false) {
115
+			return $this->TableName.'.'.$field;
116 116
 		}
117 117
 
118 118
 		return $field;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * 
123 123
 	 * @param type $param
124 124
 	 */
125
-	public function getResultQuery($table,\SimpleORM\ISpecificationCriteria $Criteria ) {
125
+	public function getResultQuery($table, \SimpleORM\ISpecificationCriteria $Criteria) {
126 126
 		
127 127
 		$this->setTable($table);
128 128
 		
@@ -141,12 +141,12 @@  discard block
 block discarded – undo
141 141
 		return $res;		
142 142
 	}
143 143
 
144
-	protected function setTable($table){
145
-		if(preg_match('~(.*?)\.(.*?)$~is',$table,$m)){
144
+	protected function setTable($table) {
145
+		if (preg_match('~(.*?)\.(.*?)$~is', $table, $m)) {
146 146
 			$this->database = $m[1];
147 147
 			$this->TableName = $m[2];
148 148
 		}
149
-		else{
149
+		else {
150 150
 			$this->TableName = $table;
151 151
 		}		
152 152
 	}	
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	protected function createSelect($joins)
161 161
 	{
162
-		$s = "`" . $this->TableName . '`.*';
162
+		$s = "`".$this->TableName.'`.*';
163 163
 		foreach ($joins as $table => $join) {
164
-			$table = isset($join['alias']) ? "`{$join['alias']}`": $table;
164
+			$table = isset($join['alias']) ? "`{$join['alias']}`" : $table;
165 165
 			$s .= ", $table.*";
166 166
 		}
167 167
 		return $s;
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	protected function buildQuery($where = array(), $limit = 25, $offset = 0, $joins = array(), $order = array(), $manualJoins = array(), $group = null, $manualWheres = array(), $whereType = 'AND')
186 186
 	{
187
-		$table = !empty($this->database)? "`{$this->database}`.".$this->TableName : $this->TableName;
188
-		$query = 'SELECT ' . $this->createSelect($joins) . " FROM `".$table."`";
187
+		$table = !empty($this->database) ? "`{$this->database}`.".$this->TableName : $this->TableName;
188
+		$query = 'SELECT '.$this->createSelect($joins)." FROM `".$table."`";
189 189
 		//$countQuery = "SELECT COUNT(*) AS cnt FROM `{$this->database}`.".$this->getTableName();
190 190
 
191 191
 		$wheres = array();
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 
196 196
 			if (!is_array($value)) {
197 197
 				$params[] = $value;
198
-				$wheres[] = $key . ' = ?';
198
+				$wheres[] = $key.' = ?';
199 199
 			} else {
200 200
 				if (isset($value['operator'])) {
201 201
 					if (is_array($value['value'])) {
202
-						if ($value['operator'] == 'between') {
202
+						if ($value['operator']=='between') {
203 203
 							$params[] = $value['value'][0];
204 204
 							$params[] = $value['value'][1];
205
-							$wheres[] = $key . ' BETWEEN ? AND ?';
206
-						} elseif ($value['operator'] == 'IN') {
205
+							$wheres[] = $key.' BETWEEN ? AND ?';
206
+						} elseif ($value['operator']=='IN') {
207 207
 							$in = array();
208 208
 
209 209
 							foreach ($value['value'] as $item) {
@@ -211,67 +211,67 @@  discard block
 block discarded – undo
211 211
 								$in[] = '?';
212 212
 							}
213 213
 
214
-							$wheres[] = $key . ' IN (' . implode(', ', $in) . ') ';
214
+							$wheres[] = $key.' IN ('.implode(', ', $in).') ';
215 215
 						} else {
216 216
 							$ors = array();
217 217
 							foreach ($value['value'] as $item) {
218
-								if ($item == 'null') {
218
+								if ($item=='null') {
219 219
 									switch ($value['operator']) {
220 220
 										case '!=':
221
-											$ors[] = $key . ' IS NOT NULL';
221
+											$ors[] = $key.' IS NOT NULL';
222 222
 											break;
223 223
 
224 224
 										case '==':
225 225
 										default:
226
-											$ors[] = $key . ' IS NULL';
226
+											$ors[] = $key.' IS NULL';
227 227
 											break;
228 228
 									}
229 229
 								} else {
230 230
 									$params[] = $item;
231
-									$ors[] = $this->fieldCheck($key) . ' ' . $value['operator'] . ' ?';
231
+									$ors[] = $this->fieldCheck($key).' '.$value['operator'].' ?';
232 232
 								}
233 233
 							}
234
-							$wheres[] = '(' . implode(' OR ', $ors) . ')';
234
+							$wheres[] = '('.implode(' OR ', $ors).')';
235 235
 						}
236 236
 					} else {
237
-						if ($value['operator'] == 'like') {
238
-							$params[] = '%' . $value['value'] . '%';
239
-							$wheres[] = $key . ' ' . $value['operator'] . ' ?';
237
+						if ($value['operator']=='like') {
238
+							$params[] = '%'.$value['value'].'%';
239
+							$wheres[] = $key.' '.$value['operator'].' ?';
240 240
 						} else {
241
-							if ($value['value'] === 'null') {
241
+							if ($value['value']==='null') {
242 242
 								switch ($value['operator']) {
243 243
 									case '!=':
244
-										$wheres[] = $key . ' IS NOT NULL';
244
+										$wheres[] = $key.' IS NOT NULL';
245 245
 										break;
246 246
 
247 247
 									case '==':
248 248
 									default:
249
-										$wheres[] = $key . ' IS NULL';
249
+										$wheres[] = $key.' IS NULL';
250 250
 										break;
251 251
 								}
252 252
 							} else {
253 253
 								$params[] = $value['value'];
254
-								$wheres[] = $key . ' ' . $value['operator'] . ' ?';
254
+								$wheres[] = $key.' '.$value['operator'].' ?';
255 255
 							}
256 256
 						}
257 257
 					}
258 258
 				} else {
259
-					$wheres[] = $key . ' IN (' . implode(', ', array_map(array($this, 'escape'), $value)) . ')';
259
+					$wheres[] = $key.' IN ('.implode(', ', array_map(array($this, 'escape'), $value)).')';
260 260
 				}
261 261
 			}
262 262
 		}
263 263
 
264 264
 		if (count($joins)) {
265 265
 			foreach ($joins as $table => $join) {
266
-				$type = isset($join['type'])?$join['type']:'INNER';
267
-				$query .= ' '. $type.' JOIN `' . $table . '` as `' . $join['alias'] . '` ON ' . $join['on'] . ' ';
266
+				$type = isset($join['type']) ? $join['type'] : 'INNER';
267
+				$query .= ' '.$type.' JOIN `'.$table.'` as `'.$join['alias'].'` ON '.$join['on'].' ';
268 268
 				//$countQuery .= ' '.$type.' JOIN ' . $table . ' ' . $join['alias'] . ' ON ' . $join['on'] . ' ';
269 269
 			}
270 270
 		}
271 271
 
272 272
 		if (count($manualJoins)) {
273 273
 			foreach ($manualJoins as $join) {
274
-				$query .= ' ' . $join . ' ';
274
+				$query .= ' '.$join.' ';
275 275
 				//$countQuery .= ' ' . $join . ' ';
276 276
 			}
277 277
 		}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		$hasWhere = false;
280 280
 		if (count($wheres)) {
281 281
 			$hasWhere = true;
282
-			$query .= ' WHERE (' . implode(' ' . $whereType . ' ', $wheres) . ')';
282
+			$query .= ' WHERE ('.implode(' '.$whereType.' ', $wheres).')';
283 283
 			//$countQuery .= ' WHERE (' . implode(' ' . $whereType . ' ', $wheres) . ')';
284 284
 		}
285 285
 
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 					$query .= ' WHERE ';
291 291
 					//$countQuery .= ' WHERE ';
292 292
 				} else {
293
-					$query .= ' ' . $where['type'] . ' ';
293
+					$query .= ' '.$where['type'].' ';
294 294
 					//$countQuery .= ' ' . $where['type'] . ' ';
295 295
 				}
296 296
 
297
-				$query .= ' ' . $where['query'];
297
+				$query .= ' '.$where['query'];
298 298
 				//$countQuery .= ' ' . $where['query'];
299 299
 
300 300
 				if (isset($where['params'])) {
@@ -306,28 +306,28 @@  discard block
 block discarded – undo
306 306
 		}
307 307
 
308 308
 		if (!is_null($group)) {
309
-			$query .= ' GROUP BY ' . $group . ' ';
309
+			$query .= ' GROUP BY '.$group.' ';
310 310
 		}
311 311
 
312 312
 		if (count($order)) {
313 313
 			$orders = array();
314
-			if (is_string($order) && $order == 'rand') {
314
+			if (is_string($order) && $order=='rand') {
315 315
 				$query .= ' ORDER BY RAND() ';
316 316
 			} else {
317 317
 				foreach ($order as $key => $value) {
318
-					$orders[] = $this->fieldCheck($key) . ' ' . $value;
318
+					$orders[] = $this->fieldCheck($key).' '.$value;
319 319
 				}
320 320
 
321
-				$query .= ' ORDER BY ' . implode(', ', $orders);
321
+				$query .= ' ORDER BY '.implode(', ', $orders);
322 322
 			}
323 323
 		}
324 324
 
325 325
 		if ($limit) {
326
-			$query .= ' LIMIT ' . $limit;
326
+			$query .= ' LIMIT '.$limit;
327 327
 		}
328 328
 
329 329
 		if ($offset) {
330
-			$query .= ' OFFSET ' . $offset;
330
+			$query .= ' OFFSET '.$offset;
331 331
 		}
332 332
 
333 333
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		try {
346 346
 			//$query = $this->compile_binds($query, $params);
347 347
 			
348
-			return $this->adapter->query($query,$params);
348
+			return $this->adapter->query($query, $params);
349 349
 			//ed( $this->adapter->query($query) ,1);
350 350
 //			if ($res = $this->adapter->getRows($query)) {
351 351
 //				$rtn = array();
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 //			} else {
360 360
 //				return false;
361 361
 //			}
362
-		} catch(\PDOException $ex) {
362
+		} catch (\PDOException $ex) {
363 363
 			throw $ex;
364 364
 		}
365 365
 	}	
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 */
375 375
 	protected function compile_binds($sql, $binds)
376 376
 	{
377
-		if (strpos($sql, $this->bind_marker) === FALSE) {
377
+		if (strpos($sql, $this->bind_marker)===FALSE) {
378 378
 			return $sql;
379 379
 		}
380 380
 
Please login to merge, or discard this patch.
tests/src/AbstractDataMapperTest.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 //								])//в конструктор
29 29
 						->disableOriginalConstructor()
30 30
 						//->setMethods(null)
31
-						->setMethods(['setMappingFields','createEntity'])
31
+						->setMethods(['setMappingFields', 'createEntity'])
32 32
 						//->setMethods(null) //не использовать заглушки методов иначе буде возвращать NULL
33 33
 						->getMock();
34 34
 	}
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
47 47
 	 */
48
-	public function testAddMappingField_SimpleField(){
48
+	public function testAddMappingField_SimpleField() {
49 49
 		
50
-		\TestHelper::callMethod($this->object,'addMappingField',['myfield']);
50
+		\TestHelper::callMethod($this->object, 'addMappingField', ['myfield']);
51 51
 		
52 52
 		$correct = [
53 53
 			  'myfield'	=>	[
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		  ];
57 57
 		
58 58
 		//-----------------
59
-		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
59
+		$mapping_fields = \TestHelper::getProtectedAttribute($this->object, 'mapping_fields');
60 60
 
61 61
         $this->assertEquals($mapping_fields, $correct);		
62 62
 	}		
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	/**
65 65
 	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
66 66
 	 */
67
-	public function testAddMappingField_FieldAndAlias(){
67
+	public function testAddMappingField_FieldAndAlias() {
68 68
 		
69
-		\TestHelper::callMethod($this->object,'addMappingField',['myfield','tb_mayfield']);
69
+		\TestHelper::callMethod($this->object, 'addMappingField', ['myfield', 'tb_mayfield']);
70 70
 		
71 71
 		$correct = [
72 72
 			  'myfield'	=>	[
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		  ];
76 76
 		
77 77
 		//-----------------
78
-		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
78
+		$mapping_fields = \TestHelper::getProtectedAttribute($this->object, 'mapping_fields');
79 79
 
80 80
         $this->assertEquals($mapping_fields, $correct);		
81 81
 	}		
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	/**
84 84
 	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
85 85
 	 */
86
-	public function testAddMappingField_ArrayField(){
86
+	public function testAddMappingField_ArrayField() {
87 87
 		
88
-		\TestHelper::callMethod($this->object,'addMappingField',['myfield',[
88
+		\TestHelper::callMethod($this->object, 'addMappingField', ['myfield', [
89 89
 			'field'	=>	'tb_mayfield'
90 90
 		]]);
91 91
 		
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		  ];
97 97
 		
98 98
 		//-----------------
99
-		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
99
+		$mapping_fields = \TestHelper::getProtectedAttribute($this->object, 'mapping_fields');
100 100
 
101 101
         $this->assertEquals($mapping_fields, $correct);		
102 102
 	}	
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 	/**
105 105
 	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
106 106
 	 */
107
-	public function testAddMappingField_PrimaryKey(){
107
+	public function testAddMappingField_PrimaryKey() {
108 108
 		
109
-		\TestHelper::callMethod($this->object,'addMappingField',['myfield',[
109
+		\TestHelper::callMethod($this->object, 'addMappingField', ['myfield', [
110 110
 			'field'		=>	'tb_mayfield',
111 111
 			'primary'	=>	true
112 112
 		]]);
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 		  ];
120 120
 		
121 121
 		//-----------------
122
-		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
122
+		$mapping_fields = \TestHelper::getProtectedAttribute($this->object, 'mapping_fields');
123 123
 
124 124
         $this->assertEquals($mapping_fields, $correct);		
125 125
 		
126
-		$key_field = \TestHelper::getProtectedAttribute($this->object,'key');
126
+		$key_field = \TestHelper::getProtectedAttribute($this->object, 'key');
127 127
 		$this->assertEquals($key_field, 'tb_mayfield');	
128 128
 	}	
129 129
 	
130 130
 	/**
131 131
 	 * @covers SimpleORM\AbstractDataMapper::AddMappingField
132 132
 	 */
133
-	public function testAddMappingField_SoftDelete(){
133
+	public function testAddMappingField_SoftDelete() {
134 134
 		
135
-		\TestHelper::callMethod($this->object,'addMappingField',['myfield',[
135
+		\TestHelper::callMethod($this->object, 'addMappingField', ['myfield', [
136 136
 			'field'			=>	'tb_mayfield',
137 137
 			'softdelete'	=>	true
138 138
 		]]);
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 		  ];
146 146
 		
147 147
 		//-----------------
148
-		$mapping_fields = \TestHelper::getProtectedAttribute($this->object,'mapping_fields');
148
+		$mapping_fields = \TestHelper::getProtectedAttribute($this->object, 'mapping_fields');
149 149
 
150 150
         $this->assertEquals($mapping_fields, $correct);		
151 151
 		
152
-		$soft_delete_key = \TestHelper::getProtectedAttribute($this->object,'soft_delete_key');
152
+		$soft_delete_key = \TestHelper::getProtectedAttribute($this->object, 'soft_delete_key');
153 153
 		$this->assertEquals($soft_delete_key, 'tb_mayfield');	
154 154
 	}	
155 155
 	
Please login to merge, or discard this patch.
tests/bootstrap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 $loader = require_once __DIR__.'/../vendor/autoload.php';
3 3
 
4
-class TestHelper{
4
+class TestHelper {
5 5
     
6 6
     /**
7 7
      * получение защищенного свойства
Please login to merge, or discard this patch.
example/Domain/City/CityMapper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 					'primary'	 => true
46 46
 					]
47 47
 				)
48
-				->addMappingField('name','cty_name')
48
+				->addMappingField('name', 'cty_name')
49 49
 			;
50 50
 
51 51
 	}	
Please login to merge, or discard this patch.
example/Domain/User/UserMapper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function createEntity(array $row) {
33 33
 		$Group = $this->DI->get('UserGroupMapper')->createEntity([]);
34
-		return $this->buildEntity(new User('testname','[email protected]','asdftyasdvh21267g',$Group), $row);
34
+		return $this->buildEntity(new User('testname', '[email protected]', 'asdftyasdvh21267g', $Group), $row);
35 35
 	}	
36 36
 	
37 37
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 					'primary'	 => true
47 47
 					]
48 48
 				)
49
-				->addMappingField('name','usr_name')
49
+				->addMappingField('name', 'usr_name')
50 50
 				->addMappingField('email', 'usr_email')
51 51
 				->addMappingField('password', 'usr_password')
52 52
 				->addMappingField('group', [
Please login to merge, or discard this patch.