Passed
Push — master ( de3595...5928a0 )
by dima
05:09
created
example/Domain/City/CityMapper.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * создаем сущность
28 28
 	 * 
29 29
 	 * @param array $row
30
-	 * @return type
30
+	 * @return \SimpleORM\EntityInterface
31 31
 	 */
32 32
 	public function createEntity(array $row) {
33 33
 		return $this->buildEntity(new City(), $row);
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
 
8 8
 namespace Test\Domain\City;
9 9
 
10
-use 
11
-	SimpleORM\AbstractDataMapper;
10
+use SimpleORM\AbstractDataMapper;
12 11
 
13 12
 /**
14 13
  * Description of PriceMapper
Please login to merge, or discard this 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/User.php 1 patch
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -22,6 +22,11 @@  discard block
 block discarded – undo
22 22
 	protected $group;
23 23
 	protected $address;
24 24
 			
25
+	/**
26
+	 * @param string $name
27
+	 * @param string $email
28
+	 * @param string $password
29
+	 */
25 30
 	function __construct($name, $email, $password, UserGroup $Group) {
26 31
 		$this->setName($name);
27 32
 		$this->setEmail($email);
@@ -64,6 +69,9 @@  discard block
 block discarded – undo
64 69
 		$this->password = $password;
65 70
 	}
66 71
 
72
+	/**
73
+	 * @param UserGroup $group
74
+	 */
67 75
 	function setGroup($group) {
68 76
 		$this->group = $group;
69 77
 	}
Please login to merge, or discard this patch.
example/Domain/UserAddress/UserAddressMapper.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * создаем сущность
28 28
 	 * 
29 29
 	 * @param array $row
30
-	 * @return type
30
+	 * @return \SimpleORM\EntityInterface
31 31
 	 */
32 32
 	public function createEntity(array $row) {
33 33
 		return $this->buildEntity(new UserAddress(), $row);
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
 
8 8
 namespace Test\Domain\UserAddress;
9 9
 
10
-use 
11
-	SimpleORM\AbstractDataMapper;
10
+use SimpleORM\AbstractDataMapper;
12 11
 
13 12
 /**
14 13
  * Description of PriceMapper
Please login to merge, or discard this 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('code','adr_code')
48
+				->addMappingField('code', 'adr_code')
49 49
 				->addMappingField('street', 'adr_street')
50 50
 				->addMappingField('city', [
51 51
 					'field'		=> 'adr_cty_id',
Please login to merge, or discard this patch.
example/Domain/UserGroup/UserGroup.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -18,6 +18,10 @@
 block discarded – undo
18 18
 	
19 19
 	protected $title;
20 20
 	
21
+	/**
22
+	 * @param string $code
23
+	 * @param string $title
24
+	 */
21 25
 	function __construct($code,$title){
22 26
 		$this->setCode($code);
23 27
 		$this->setTitle($title);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 	
19 19
 	protected $title;
20 20
 	
21
-	function __construct($code,$title){
21
+	function __construct($code, $title) {
22 22
 		$this->setCode($code);
23 23
 		$this->setTitle($title);
24 24
 	}
Please login to merge, or discard this patch.
src/AbstractDataMapper.php 3 patches
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	/**
304 304
 	 * Подготавливаем конечный вариант Сущности
305 305
 	 * 
306
-	 * @param \Core\Infrastructure\EntityInterface $Entity
306
+	 * @param EntityInterface $Entity
307 307
 	 * @param array $row
308
-	 * @return \Core\Infrastructure\EntityInterface
308
+	 * @return EntityInterface
309 309
 	 * @throws BadMethodCallException
310 310
 	 */
311 311
 	protected function buildEntity(EntityInterface $Entity, array $row){
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	
356 356
 	/**
357 357
 	 * из объекта формирует массив
358
-	 * @param \Core\Infrastructure\EntityInterface $Entity
358
+	 * @param EntityInterface $Entity
359 359
 	 * @return \Core\Infrastructure\EntityInterface
360 360
 	 * @throws BadMethodCallException
361 361
 	 */
@@ -400,6 +400,7 @@  discard block
 block discarded – undo
400 400
 	
401 401
 	/**
402 402
 	 * Установка поля для маппинга
403
+	 * @param string $alias
403 404
 	 */
404 405
 	protected function addMappingField($alias,$field = null){
405 406
 		
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		
81 81
 		$this->setEntityTable($db_name);
82 82
 		
83
-		if($this->getEntityTable()=='' || $this->getPrimaryKey()==''){
83
+		if ($this->getEntityTable()=='' || $this->getPrimaryKey()=='') {
84 84
 			throw new InvalidEntityPropertyException('Свойства entityTable или key не заданы');
85 85
 		}		
86 86
 		
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         return $this->adapter;
93 93
     }
94 94
 
95
-	public function setAdapter(QueryBuilderInterface $adapter){
95
+	public function setAdapter(QueryBuilderInterface $adapter) {
96 96
 		 $this->adapter = $adapter;
97 97
 	}
98 98
 			
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * Уставнока таблицы
106 106
 	 */
107 107
 	protected function setEntityTable($db_name) {
108
-		$this->entityTable = !empty($db_name)? "$db_name.".$this->table : $this->table;
108
+		$this->entityTable = !empty($db_name) ? "$db_name.".$this->table : $this->table;
109 109
 	}	
110 110
 
111 111
 	/**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
     public function findById($id)
117 117
     {
118
-		$Criteria = (new Specification())->setWhere($this->key , $id);
118
+		$Criteria = (new Specification())->setWhere($this->key, $id);
119 119
 		
120 120
         return $this->findBySpecification($Criteria);
121 121
     }	
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			
137 137
 			unset($data[$this->setSoftDeleteKey()]);
138 138
 			
139
-			$this->getAdapter()->insert($this->getEntityTable(),$data);
139
+			$this->getAdapter()->insert($this->getEntityTable(), $data);
140 140
 			
141 141
 			if (!$id = $this->getAdapter()->insert_id()) {
142 142
 				return false;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		//update
148 148
 		else {
149 149
 			
150
-			if(!$this->getAdapter()->update($this->getEntityTable(), $data, "{$this->getPrimaryKey()} = '{$id}'")){
150
+			if (!$this->getAdapter()->update($this->getEntityTable(), $data, "{$this->getPrimaryKey()} = '{$id}'")) {
151 151
 				return false;
152 152
 			}
153 153
 
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function save(EntityInterface $Entity)
164 164
 	{
165
-		if(method_exists($this, 'onAfterSave' )) $this->onAfterSave( $Entity );
165
+		if (method_exists($this, 'onAfterSave')) $this->onAfterSave($Entity);
166 166
 		
167
-		if(!$this->saveWithoutEvents($Entity)){
167
+		if (!$this->saveWithoutEvents($Entity)) {
168 168
 			return false;
169 169
 		}
170 170
 		
171
-		if(method_exists($this, 'onBeforeSave' )) $this->onBeforeSave( $Entity );
171
+		if (method_exists($this, 'onBeforeSave')) $this->onBeforeSave($Entity);
172 172
 
173 173
 		return true;
174 174
 	}
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
 	 * Событие перед сохранением
178 178
 	 * @param \SimpleORM\EntityInterface $Entity
179 179
 	 */
180
-	public function onAfterSave(EntityInterface $Entity){
180
+	public function onAfterSave(EntityInterface $Entity) {
181 181
 		
182 182
 		$this->getAdapter()->startTransaction();
183 183
 		
184 184
 		$rel_list = $this->createListRelation();
185 185
 
186
-		foreach ($rel_list as $mapper => $obj_path){
186
+		foreach ($rel_list as $mapper => $obj_path) {
187 187
 
188
-			$get_path = str_replace('#','->get','$o = $Entity'.$obj_path.';');
189
-			$set_path = str_replace(['#','();'],['->set','($o);'],'$Entity'.$obj_path.';');
190
-			eval($get_path);//получаем объект таким образом дабы не гулять по корневому объекту
191
-			if($this->DI->get($mapper)->saveWithoutEvents($o)){
188
+			$get_path = str_replace('#', '->get', '$o = $Entity'.$obj_path.';');
189
+			$set_path = str_replace(['#', '();'], ['->set', '($o);'], '$Entity'.$obj_path.';');
190
+			eval($get_path); //получаем объект таким образом дабы не гулять по корневому объекту
191
+			if ($this->DI->get($mapper)->saveWithoutEvents($o)) {
192 192
 				eval($set_path);
193 193
 			}
194 194
 			unset($o);
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * После успешного сохранения
201 201
 	 * @param \SimpleORM\EntityInterface $Entity
202 202
 	 */
203
-	protected function onBeforeSave(EntityInterface $Entity){
203
+	protected function onBeforeSave(EntityInterface $Entity) {
204 204
 		
205 205
 		$this->getAdapter()->endTransaction();
206 206
 		
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
 	 * получение мапперов в порядке их использования с учетом вложенности
224 224
 	 * @return array
225 225
 	 */
226
-	protected function createListRelation(){
226
+	protected function createListRelation() {
227 227
 		$rel_list = [];
228 228
 		
229 229
 		$rel_map = $this->getRelations();
230 230
 		
231
-		$this->createListRelationReq($rel_map,$rel_list);
231
+		$this->createListRelationReq($rel_map, $rel_list);
232 232
 		
233 233
 		return $rel_list;
234 234
 	}
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
 	 * @param array $rel_map
239 239
 	 * @param type $rel_list
240 240
 	 */
241
-	protected function createListRelationReq(array $rel_map,&$rel_list,$obj_parent_link = null) {
241
+	protected function createListRelationReq(array $rel_map, &$rel_list, $obj_parent_link = null) {
242 242
 		
243
-		foreach ($rel_map as $rel){
243
+		foreach ($rel_map as $rel) {
244 244
 			
245 245
 			$obj_link = $parent.'#'.$rel['alias'].'()';
246 246
 			
247
-			if(count($rel['relations'])>0){
248
-				$this->createListRelationReq($rel['relations'],$rel_list,$parent.'->get'.$rel['alias'].'()');
249
-				$rel_list [$rel['name']]= $obj_parent_link.$obj_link;
247
+			if (count($rel['relations']) > 0) {
248
+				$this->createListRelationReq($rel['relations'], $rel_list, $parent.'->get'.$rel['alias'].'()');
249
+				$rel_list [$rel['name']] = $obj_parent_link.$obj_link;
250 250
 			}
251
-			else{
251
+			else {
252 252
 				$rel_list [$rel['name']] = $obj_parent_link.$obj_link;
253 253
 			}
254 254
 		}
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
 		foreach ($this->relations as $alias => $cfg) {
264 264
 			$mapper = $cfg['mapper'];
265 265
 			//если связь один к одному то удаляем сущность
266
-			if($cgg['reltype'] == 'has_one'){
266
+			if ($cgg['reltype']=='has_one') {
267 267
 				$Entity = $Entity->{'get'.$alias}();
268
-				if(!$mapper->delete($Entity)){
268
+				if (!$mapper->delete($Entity)) {
269 269
 					throw new \Autoprice\Exceptions\EntityNotDeleteException('Unable to delete Entity!');
270 270
 				}
271 271
 			}
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * получить связи
281 281
 	 */
282
-	protected function getRelations(){
282
+	protected function getRelations() {
283 283
 		$rel_map = [];
284
-		foreach ($this->mapping_fields as $field => $cfg){
285
-			if(isset($cfg['relation'])){		
284
+		foreach ($this->mapping_fields as $field => $cfg) {
285
+			if (isset($cfg['relation'])) {		
286 286
 				$rels = $this->DI->get($cfg['relation'])->getRelations();
287
-				$rel_map []= [
287
+				$rel_map [] = [
288 288
 					'name'		=>	$cfg['relation'],
289 289
 					'alias'		=>	$field,
290 290
 					'relations'	=>	$rels
@@ -308,43 +308,43 @@  discard block
 block discarded – undo
308 308
 	 * @return \Core\Infrastructure\EntityInterface
309 309
 	 * @throws BadMethodCallException
310 310
 	 */
311
-	protected function buildEntity(EntityInterface $Entity, array $row){
311
+	protected function buildEntity(EntityInterface $Entity, array $row) {
312 312
 		
313
-        foreach ($this->mapping_fields as $alias => $cfg ) {
313
+        foreach ($this->mapping_fields as $alias => $cfg) {
314 314
 			
315 315
 			$value = false;
316 316
 			
317 317
 			$field = $cfg['field'];
318 318
 			
319
-			$method_set = 'set' . ucfirst($alias);
319
+			$method_set = 'set'.ucfirst($alias);
320 320
 			
321
-			if(!method_exists($Entity, $method_set )){
321
+			if (!method_exists($Entity, $method_set)) {
322 322
 				throw new BadMethodCallException("Метод {$method_set}  не определен");
323 323
 			}			
324 324
 			
325 325
 			//событие на формирование поля
326
-			if( isset($cfg['build']) && is_object($cfg['build']) ){
326
+			if (isset($cfg['build']) && is_object($cfg['build'])) {
327 327
 				$value = call_user_func($cfg['build'], $row);
328 328
 			}
329 329
 			//на связь
330
-			elseif(isset($cfg['relation'])){
330
+			elseif (isset($cfg['relation'])) {
331 331
 				
332 332
 				$mapper = $this->DI->get($cfg['relation']);
333 333
 				
334
-				if($this->use_joins===true || empty($row[$field])){
334
+				if ($this->use_joins===true || empty($row[$field])) {
335 335
 					$value = $mapper->createEntity($row);
336 336
 				}
337
-				else{
338
-					$fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key;
337
+				else {
338
+					$fkey = isset($cfg['on']) ? $cfg['on'] : $mapper->key;
339 339
 					$value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field]));
340 340
 				}				
341 341
 				
342 342
 			}
343
-			elseif(is_string($field) && isset($row[strtolower($field)])){
343
+			elseif (is_string($field) && isset($row[strtolower($field)])) {
344 344
 				$value = $row[strtolower($field)];
345 345
 			}
346 346
 			
347
-			if($value!==false)
347
+			if ($value!==false)
348 348
 				$Entity->{$method_set}($value);
349 349
 			
350 350
         }
@@ -359,27 +359,27 @@  discard block
 block discarded – undo
359 359
 	 * @return \Core\Infrastructure\EntityInterface
360 360
 	 * @throws BadMethodCallException
361 361
 	 */
362
-	protected function unbuildEntity(EntityInterface $Entity){
362
+	protected function unbuildEntity(EntityInterface $Entity) {
363 363
 		
364 364
 		$row = [];
365 365
 
366
-        foreach ($this->mapping_fields as $alias => $cfg ) {
366
+        foreach ($this->mapping_fields as $alias => $cfg) {
367 367
 			
368 368
 			$field = $cfg['field'];
369 369
 			
370
-			$method_get = 'get' . ucfirst($alias);
370
+			$method_get = 'get'.ucfirst($alias);
371 371
 			
372
-			if(!method_exists($Entity, $method_get )){
372
+			if (!method_exists($Entity, $method_get)) {
373 373
 				throw new BadMethodCallException("Метод {$method_get}  не определен");
374 374
 			}		
375 375
 			
376 376
 			//--------------------------------------------------------------------
377
-			if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){
378
-				$value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() );
377
+			if (isset($cfg['unbuild']) && is_object($cfg['unbuild'])) {
378
+				$value = call_user_func($cfg['unbuild'], $Entity->{$method_get}());
379 379
 			}
380
-			elseif(isset($cfg['relation'])){
380
+			elseif (isset($cfg['relation'])) {
381 381
 				
382
-				if(isset($cfg['on']))
382
+				if (isset($cfg['on']))
383 383
 					$fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']);
384 384
 				else
385 385
 					$fkey = 'id';
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 				$value = $Entity->{$method_get}()->{'get'.$fkey}();
388 388
 				
389 389
 			}			
390
-			else{
390
+			else {
391 391
 				$value = $Entity->{$method_get}();
392 392
 			}			
393 393
 						
@@ -401,22 +401,22 @@  discard block
 block discarded – undo
401 401
 	/**
402 402
 	 * Установка поля для маппинга
403 403
 	 */
404
-	protected function addMappingField($alias,$field = null){
404
+	protected function addMappingField($alias, $field = null) {
405 405
 		
406
-		if(is_string($field)){
406
+		if (is_string($field)) {
407 407
 			$field = ['field'	=>	$field];
408 408
 		}
409
-		elseif( (is_array($field) && !isset($field['field'])) || empty($field)){
410
-			$field['field']	= $alias;
409
+		elseif ((is_array($field) && !isset($field['field'])) || empty($field)) {
410
+			$field['field'] = $alias;
411 411
 		}
412 412
 	
413 413
 		$this->mapping_fields[$alias] = $field;
414 414
 
415
-		if(isset($field['primary']) && $field['primary']===true){
415
+		if (isset($field['primary']) && $field['primary']===true) {
416 416
 			$this->key = $field['field'];
417 417
 		}
418 418
 		
419
-		if(isset($field['softdelete']) && $field['softdelete']===true){
419
+		if (isset($field['softdelete']) && $field['softdelete']===true) {
420 420
 			$this->soft_delete_key = $field['field'];
421 421
 		}
422 422
 		
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 
444 444
 
445 445
 	
446
-	public function getFieldAlias($field){
446
+	public function getFieldAlias($field) {
447 447
 		
448 448
 		return $this->mapping_fields_aliases[$field];
449 449
 		
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 	 * @param ISpecificationCriteria $specification
456 456
 	 * @return type
457 457
 	 */
458
-	public function findBySpecification(ISpecificationCriteria $specification){
458
+	public function findBySpecification(ISpecificationCriteria $specification) {
459 459
 
460 460
 		//псеводо удаление
461 461
 		$this->setSoftDelete($specification);
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 		$specification->setLimit(1);
466 466
 		
467 467
 		//получение записей
468
-		$res = $this->getAdapter()->getResultQuery($this->getEntityTable(),$specification);
468
+		$res = $this->getAdapter()->getResultQuery($this->getEntityTable(), $specification);
469 469
 
470 470
         if (!$row = $res->row_array()) {
471 471
             return null;
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 		
487 487
 		if (
488 488
 				$delete_key > '' && 
489
-				$Entity->getId() > 0){
490
-				$result = $this->getAdapter()->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'");
489
+				$Entity->getId() > 0) {
490
+				$result = $this->getAdapter()->update($this->getEntityTable(), [$delete_key => 1], "{$this->getPrimaryKey()} = '{$Entity->getId()}'");
491 491
 		}
492
-		elseif($Entity->getId() > 0){
492
+		elseif ($Entity->getId() > 0) {
493 493
 			
494
-			if($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()."  = ".$Entity->getId())){
495
-				if(method_exists($this, 'onBeforeDelete' )){ $result = $this->onBeforeDelete( $Entity );}
494
+			if ($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()."  = ".$Entity->getId())) {
495
+				if (method_exists($this, 'onBeforeDelete')) { $result = $this->onBeforeDelete($Entity); }
496 496
 			}
497 497
 		}
498 498
 		
@@ -509,13 +509,13 @@  discard block
 block discarded – undo
509 509
 		
510 510
 		$this->setRelations($specification);
511 511
 		
512
-		$res = $this->getAdapter()->getResultQuery($this->getEntityTable(),$specification);
512
+		$res = $this->getAdapter()->getResultQuery($this->getEntityTable(), $specification);
513 513
 		
514 514
 		if (!$rows = $res->result_array()) {
515 515
             return null;
516 516
         }	
517 517
 		
518
-		foreach($rows as $k =>  $row){
518
+		foreach ($rows as $k =>  $row) {
519 519
 			$rows[$k] = $this->createEntity($row);
520 520
 		}
521 521
 		
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
 	 * Выборка удаленных моделей
532 532
 	 * @param ISpecificationCriteria $specification
533 533
 	 */
534
-	private function setSoftDelete(ISpecificationCriteria $specification){
535
-		if(
536
-				$this->use_delete === false &&
537
-				$this->setSoftDeleteKey()>'' 
534
+	private function setSoftDelete(ISpecificationCriteria $specification) {
535
+		if (
536
+				$this->use_delete===false &&
537
+				$this->setSoftDeleteKey() > '' 
538 538
 				&& !isset($specification->getWhere()[$this->setSoftDeleteKey()])
539 539
 				)
540
-		$specification->setWhere($this->setSoftDeleteKey(),0);
540
+		$specification->setWhere($this->setSoftDeleteKey(), 0);
541 541
 	}
542 542
 	
543 543
 	/**
@@ -548,12 +548,12 @@  discard block
 block discarded – undo
548 548
 	 * belongs_to - многие к многим (пользователь имет множество оплат одного заказа)
549 549
 	 * has_one - один к одному
550 550
 	 */
551
-	protected function setRelations(ISpecificationCriteria $Specification){
551
+	protected function setRelations(ISpecificationCriteria $Specification) {
552 552
 
553 553
 		$joins = [];
554 554
 
555
-		foreach ($this->mapping_fields as $field => $cfg){
556
-			if(isset($cfg['relation'])){
555
+		foreach ($this->mapping_fields as $field => $cfg) {
556
+			if (isset($cfg['relation'])) {
557 557
 				
558 558
 				$this->relations[$field] = [
559 559
 					'mapper'	=>	$mapper = $this->DI->get($cfg['relation']),
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 
563 563
 				$table = $mapper->getEntityTable();
564 564
 
565
-				$relation_key = isset($cfg['on'])? $cfg['on'] : $mapper->key;
565
+				$relation_key = isset($cfg['on']) ? $cfg['on'] : $mapper->key;
566 566
 				
567 567
 				$joins[$table] = [
568 568
 						'alias'	=> $field,
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			}
574 574
 		}	
575 575
 
576
-		if($this->use_joins===true){
576
+		if ($this->use_joins===true) {
577 577
 			$Specification->setJoins($joins);
578 578
 		}			
579 579
 	}
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 		return $o;
589 589
 	}
590 590
 	
591
-	public function withDelete(){
591
+	public function withDelete() {
592 592
 		$o = clone $this;
593 593
 		$o->use_delete = true;
594 594
 		return $o;
Please login to merge, or discard this patch.
Braces   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -162,13 +162,17 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function save(EntityInterface $Entity)
164 164
 	{
165
-		if(method_exists($this, 'onAfterSave' )) $this->onAfterSave( $Entity );
165
+		if(method_exists($this, 'onAfterSave' )) {
166
+			$this->onAfterSave( $Entity );
167
+		}
166 168
 		
167 169
 		if(!$this->saveWithoutEvents($Entity)){
168 170
 			return false;
169 171
 		}
170 172
 		
171
-		if(method_exists($this, 'onBeforeSave' )) $this->onBeforeSave( $Entity );
173
+		if(method_exists($this, 'onBeforeSave' )) {
174
+			$this->onBeforeSave( $Entity );
175
+		}
172 176
 
173 177
 		return true;
174 178
 	}
@@ -247,8 +251,7 @@  discard block
 block discarded – undo
247 251
 			if(count($rel['relations'])>0){
248 252
 				$this->createListRelationReq($rel['relations'],$rel_list,$parent.'->get'.$rel['alias'].'()');
249 253
 				$rel_list [$rel['name']]= $obj_parent_link.$obj_link;
250
-			}
251
-			else{
254
+			} else{
252 255
 				$rel_list [$rel['name']] = $obj_parent_link.$obj_link;
253 256
 			}
254 257
 		}
@@ -333,19 +336,18 @@  discard block
 block discarded – undo
333 336
 				
334 337
 				if($this->use_joins===true || empty($row[$field])){
335 338
 					$value = $mapper->createEntity($row);
336
-				}
337
-				else{
339
+				} else{
338 340
 					$fkey = isset($cfg['on']) ? $cfg['on'] :$mapper->key;
339 341
 					$value = $mapper->findBySpecification((new Specification)->setWhere($fkey, $row[$field]));
340 342
 				}				
341 343
 				
342
-			}
343
-			elseif(is_string($field) && isset($row[strtolower($field)])){
344
+			} elseif(is_string($field) && isset($row[strtolower($field)])){
344 345
 				$value = $row[strtolower($field)];
345 346
 			}
346 347
 			
347
-			if($value!==false)
348
-				$Entity->{$method_set}($value);
348
+			if($value!==false) {
349
+							$Entity->{$method_set}($value);
350
+			}
349 351
 			
350 352
         }
351 353
 		
@@ -376,18 +378,17 @@  discard block
 block discarded – undo
376 378
 			//--------------------------------------------------------------------
377 379
 			if( isset($cfg['unbuild']) && is_object($cfg['unbuild']) ){
378 380
 				$value = call_user_func($cfg['unbuild'], $Entity->{$method_get}() );
379
-			}
380
-			elseif(isset($cfg['relation'])){
381
+			} elseif(isset($cfg['relation'])){
381 382
 				
382
-				if(isset($cfg['on']))
383
-					$fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']);
384
-				else
385
-					$fkey = 'id';
383
+				if(isset($cfg['on'])) {
384
+									$fkey = $this->DI->get($cfg['relation'])->getFieldAlias($cfg['on']);
385
+				} else {
386
+									$fkey = 'id';
387
+				}
386 388
 				
387 389
 				$value = $Entity->{$method_get}()->{'get'.$fkey}();
388 390
 				
389
-			}			
390
-			else{
391
+			} else{
391 392
 				$value = $Entity->{$method_get}();
392 393
 			}			
393 394
 						
@@ -405,8 +406,7 @@  discard block
 block discarded – undo
405 406
 		
406 407
 		if(is_string($field)){
407 408
 			$field = ['field'	=>	$field];
408
-		}
409
-		elseif( (is_array($field) && !isset($field['field'])) || empty($field)){
409
+		} elseif( (is_array($field) && !isset($field['field'])) || empty($field)){
410 410
 			$field['field']	= $alias;
411 411
 		}
412 412
 	
@@ -488,8 +488,7 @@  discard block
 block discarded – undo
488 488
 				$delete_key > '' && 
489 489
 				$Entity->getId() > 0){
490 490
 				$result = $this->getAdapter()->update($this->getEntityTable(), [ $delete_key => 1 ], "{$this->getPrimaryKey()} = '{$Entity->getId()}'");
491
-		}
492
-		elseif($Entity->getId() > 0){
491
+		} elseif($Entity->getId() > 0){
493 492
 			
494 493
 			if($result = $this->getAdapter()->delete($this->getEntityTable(), $this->getPrimaryKey()."  = ".$Entity->getId())){
495 494
 				if(method_exists($this, 'onBeforeDelete' )){ $result = $this->onBeforeDelete( $Entity );}
@@ -536,8 +535,9 @@  discard block
 block discarded – undo
536 535
 				$this->use_delete === false &&
537 536
 				$this->setSoftDeleteKey()>'' 
538 537
 				&& !isset($specification->getWhere()[$this->setSoftDeleteKey()])
539
-				)
540
-		$specification->setWhere($this->setSoftDeleteKey(),0);
538
+				) {
539
+				$specification->setWhere($this->setSoftDeleteKey(),0);
540
+		}
541 541
 	}
542 542
 	
543 543
 	/**
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.
example/Domain/UserAddress/UserAddress.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 	
22 22
 	protected $city;
23 23
 
24
-	function __construct(\Test\Domain\City\City $City,$code,$street) {
24
+	function __construct(\Test\Domain\City\City $City, $code, $street) {
25 25
 		$this->setCity($City);
26 26
 		$this->setCode($code);
27 27
 		$this->setStreet($street);
Please login to merge, or discard this patch.
example/Domain/UserGroup/UserGroupMapper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @return type
31 31
 	 */
32 32
 	public function createEntity(array $row) {
33
-		return $this->buildEntity(new UserGroup('admin','admin test'), $row);
33
+		return $this->buildEntity(new UserGroup('admin', 'admin test'), $row);
34 34
 	}	
35 35
 	
36 36
 	/**
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 					'primary'	 => true
46 46
 					]
47 47
 				)
48
-				->addMappingField('title','grp_title')
49
-				->addMappingField('code','grp_code')
48
+				->addMappingField('title', 'grp_title')
49
+				->addMappingField('code', 'grp_code')
50 50
 			;
51 51
 
52 52
 	}	
Please login to merge, or discard this patch.
example/ServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@
 block discarded – undo
24 24
 		
25 25
 		$db = new \SimpleORM\Adapter\CodeigniterQueryBuilder(get_instance()->db);
26 26
 		
27
-		$this->getContainer()->add('UserMapper','Test\Domain\User\UserMapper')
27
+		$this->getContainer()->add('UserMapper', 'Test\Domain\User\UserMapper')
28 28
 				->withArgument($this->getContainer())
29 29
 				->withArgument($db)
30 30
 				->withArgument($__AR2['autoresource_db']);
31 31
 		
32
-		$this->getContainer()->add('UserGroupMapper','Test\Domain\UserGroup\UserGroupMapper')
32
+		$this->getContainer()->add('UserGroupMapper', 'Test\Domain\UserGroup\UserGroupMapper')
33 33
 				->withArgument($this->getContainer())
34 34
 				->withArgument($db)
35 35
 				->withArgument($__AR2['autoresource_db']);	
36
-		$this->getContainer()->add('UserAddressMapper','Test\Domain\UserAddress\UserAddressMapper')
36
+		$this->getContainer()->add('UserAddressMapper', 'Test\Domain\UserAddress\UserAddressMapper')
37 37
 				->withArgument($this->getContainer())
38 38
 				->withArgument($db)
39 39
 				->withArgument($__AR2['autoresource_db']);	
40
-		$this->getContainer()->add('CityMapper','Test\Domain\City\CityMapper')
40
+		$this->getContainer()->add('CityMapper', 'Test\Domain\City\CityMapper')
41 41
 				->withArgument($this->getContainer())
42 42
 				->withArgument($db)
43 43
 				->withArgument($__AR2['autoresource_db']);	
Please login to merge, or discard this patch.