Code Duplication    Length = 30-30 lines in 2 locations

src/Scaffolder/Compilers/Core/ControllerCompiler.php 1 location

@@ 477-506 (lines=30) @@
474
	 * @return $this
475
	 */
476
	private $conditionsStub = [];
477
	private function getConditionStubByField($field){
478
		
479
		if($field->index == 'primary'){
480
			$dbType = 'primary' ;
481
		}
482
		elseif($field->foreignKey){
483
			$dbType = 'primary' ;
484
		}
485
		elseif($field->type->db == 'enum'){
486
			$dbType = 'primary' ;
487
		}
488
		elseif($field->type->db == 'boolean'){
489
			$dbType = 'primary' ;
490
		}
491
		elseif($field->type->db == 'text'){
492
			$dbType = 'string' ;
493
		}
494
		else {
495
			$dbType = $field->type->db ;
496
		}
497
498
		if(array_key_exists($dbType, $this->conditionsStub)){
499
			return $this->conditionsStub[$dbType];
500
		}
501
		else {
502
			$this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');;
503
504
			return $this->conditionsStub[$dbType];
505
		}
506
	}
507
	
508
509

src/Scaffolder/Compilers/Core/ModelCompiler.php 1 location

@@ 531-560 (lines=30) @@
528
	 * @return $this
529
	 */
530
	private $conditionsStub = [];
531
	private function getConditionStubByField($field){
532
		
533
		if($field->index == 'primary'){
534
			$dbType = 'primary' ;
535
		}
536
		elseif($field->foreignKey){
537
			$dbType = 'primary' ;
538
		}
539
		elseif($field->type->db == 'enum'){
540
			$dbType = 'primary' ;
541
		}
542
		elseif($field->type->db == 'boolean'){
543
			$dbType = 'primary' ;
544
		}
545
		elseif($field->type->db == 'text'){
546
			$dbType = 'string' ;
547
		}
548
		else {
549
			$dbType = $field->type->db ;
550
		}
551
552
		if(array_key_exists($dbType, $this->conditionsStub)){
553
			return $this->conditionsStub[$dbType];
554
		}
555
		else {
556
			$this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');;
557
558
			return $this->conditionsStub[$dbType];
559
		}
560
	}
561
562
	public function replaceSortConditions()	{
563
		$joinSorts = '';