Code Duplication    Length = 22-23 lines in 3 locations

src/Scaffolder/Compilers/Core/ControllerCompiler.php 2 locations

@@ 116-137 (lines=22) @@
113
	}
114
115
116
	public function replaceSortConditions()	{
117
		$joinSorts = '';
118
119
		foreach ($this->modelData->fields as $field) {
120
			if($field->foreignKey){
121
				$joinSortStub = File::get($this->stubsDirectory . 'SearchConditions/JoinSort.php');
122
				$joinSortStub = str_replace('{{field}}', $field->name, $joinSortStub);
123
				$joinSortStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $joinSortStub);
124
				$joinSortStub = str_replace('{{foreign_key}}', $field->foreignKey->table, $joinSortStub);
125
				$joinSorts .= $joinSortStub;
126
127
			}
128
			
129
	
130
			
131
		}
132
		
133
134
		$this->stub = str_replace('{{relationship_tables_joins_sort}}', $joinSorts, $this->stub);
135
136
		return $this;
137
	}
138
139
	public function replaceUniqueRules() {
140
		$uniqueRules = '';
@@ 311-333 (lines=23) @@
308
	 *
309
	 * @return $this
310
	 */
311
	public function replaceEnum(){
312
313
		$functions = '';
314
315
		$method = File::get($this->stubsDirectory . '/Controller/ControllerEnum.php');
316
317
		foreach ($this->modelData->fields as $field)
318
		{
319
			if ($field->type->db == "enum") {
320
				$replacedMethod = '';
321
				$replacedMethod = str_replace('{{field_name_uc}}', CamelCase::convertToCamelCase($field->name), $method);	
322
				$replacedMethod = str_replace('{{field_name}}', $field->name, $replacedMethod);
323
				$replacedMethod = str_replace('{{model_name}}', $this->modelData->modelName, $replacedMethod);
324
				
325
				$functions .= $replacedMethod;
326
			}
327
		}
328
329
		$this->stub = str_replace('{{enum}}', $functions, $this->stub);
330
331
		return $this;
332
333
	}
334
335
	/**
336
	 * replace relationship tables

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

@@ 562-583 (lines=22) @@
559
		}
560
	}
561
562
	public function replaceSortConditions()	{
563
		$joinSorts = '';
564
565
		foreach ($this->modelData->fields as $field) {
566
			if($field->foreignKey){
567
				$joinSortStub = File::get($this->stubsDirectory . 'SearchConditions/JoinSort.php');
568
				$joinSortStub = str_replace('{{field}}', $field->name, $joinSortStub);
569
				$joinSortStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $joinSortStub);
570
				$joinSortStub = str_replace('{{foreign_key}}', $field->foreignKey->table, $joinSortStub);
571
				$joinSorts .= $joinSortStub;
572
573
			}
574
			
575
	
576
			
577
		}
578
		
579
580
		$this->stub = str_replace('{{relationship_tables_joins_sort}}', $joinSorts, $this->stub);
581
582
		return $this;
583
	}
584
585
586