Code Duplication    Length = 23-23 lines in 2 locations

src/command/GenerateApiCommand.php 2 locations

@@ 199-221 (lines=23) @@
196
			'update' => 'Updates the relationship of {model} to {foreign}'
197
		];
198
		
199
		foreach (array_keys($generators) as $type) {
200
			// generate fqcn
201
			$className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type));
202
			$fqcn = $this->modelService->getRootNamespace() . '\\action\\' . $className;
203
				
204
			// generate action
205
			$action = new ActionSchema($actionNamePrefix . '-' . $type);
206
			$action->addAcl('admin');
207
			$action->setClass($fqcn);
208
			$action->setTitle(str_replace(
209
				['{model}', '{foreign}'],
210
				[$model->getOriginCommonName(), $foreign->getoriginCommonName()],
211
				$titles[$type])
212
			);
213
			$action->setResponse('json', $response);
214
			$module->addAction($action);
215
			$actions[$type] = $action;
216
				
217
			// generate class
218
			$generator = $generators[$type];
219
			$class = $generator->generate(new PhpClass($fqcn), $model, $foreign);
220
			$this->codegenService->dumpStruct($class, true);
221
		}
222
		
223
		// generate response class
224
		$generator = new ToOneRelationshipJsonResponseGenerator($this->service, $model, $foreign);
@@ 300-322 (lines=23) @@
297
			'remove' => 'Removes {foreign} as relationship of {model}'
298
		];
299
		
300
		foreach (array_keys($generators) as $type) {
301
			// generate fqcn
302
			$className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type));
303
			$fqcn = $this->modelService->getRootNamespace() . '\\action\\' . $className;
304
			
305
			// generate action
306
			$action = new ActionSchema($actionNamePrefix . '-' . $type);
307
			$action->addAcl('admin');
308
			$action->setClass($fqcn);
309
			$action->setTitle(str_replace(
310
				['{model}', '{foreign}'],
311
				[$model->getOriginCommonName(), $foreign->getoriginCommonName()], 
312
				$titles[$type])
313
			);
314
			$action->setResponse('json', $response);
315
			$module->addAction($action);
316
			$actions[$type] = $action;
317
			
318
			// generate class
319
			$generator = $generators[$type];
320
			$class = $generator->generate(new PhpClass($fqcn), $model, $foreign, $middle);
321
			$this->codegenService->dumpStruct($class, true);
322
		}
323
		
324
		// generate response class
325
		$generator = new ToManyRelationshipJsonResponseGenerator($this->service, $model, $foreign);