Code Duplication    Length = 23-23 lines in 2 locations

src/command/GenerateApiCommand.php 2 locations

@@ 191-213 (lines=23) @@
188
			'update' => 'Updates the relationship of {model} to {foreign}'
189
		];
190
		
191
		foreach (array_keys($generators) as $type) {
192
			// generate fqcn
193
			$className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type));
194
			$fqcn = $this->modelService->getRootNamespace() . '\\action\\' . $className;
195
				
196
			// generate action
197
			$action = new ActionSchema($actionNamePrefix . '-' . $type);
198
			$action->addAcl('admin');
199
			$action->setClass($fqcn);
200
			$action->setTitle(str_replace(
201
				['{model}', '{foreign}'],
202
				[$model->getOriginCommonName(), $foreign->getoriginCommonName()],
203
				$titles[$type])
204
			);
205
			$action->setResponse('json', $response);
206
			$module->addAction($action);
207
			$actions[$type] = $action;
208
				
209
			// generate class
210
			$generator = $generators[$type];
211
			$class = $generator->generate(new PhpClass($fqcn), $model, $foreign);
212
			$this->codegenService->dumpStruct($class, true);
213
		}
214
		
215
		// generate response class
216
		$generator = new ToOneRelationshipJsonResponseGenerator($this->service, $model, $foreign);
@@ 292-314 (lines=23) @@
289
			'remove' => 'Removes {foreign} as relationship of {model}'
290
		];
291
		
292
		foreach (array_keys($generators) as $type) {
293
			// generate fqcn
294
			$className = sprintf('%s%s%sAction', $model->getPhpName(), $fkModelName, ucfirst($type));
295
			$fqcn = $this->modelService->getRootNamespace() . '\\action\\' . $className;
296
			
297
			// generate action
298
			$action = new ActionSchema($actionNamePrefix . '-' . $type);
299
			$action->addAcl('admin');
300
			$action->setClass($fqcn);
301
			$action->setTitle(str_replace(
302
				['{model}', '{foreign}'],
303
				[$model->getOriginCommonName(), $foreign->getoriginCommonName()], 
304
				$titles[$type])
305
			);
306
			$action->setResponse('json', $response);
307
			$module->addAction($action);
308
			$actions[$type] = $action;
309
			
310
			// generate class
311
			$generator = $generators[$type];
312
			$class = $generator->generate(new PhpClass($fqcn), $model, $foreign, $middle);
313
			$this->codegenService->dumpStruct($class, true);
314
		}
315
		
316
		// generate response class
317
		$generator = new ToManyRelationshipJsonResponseGenerator($this->service, $model, $foreign);