Conditions | 7 |
Paths | 9 |
Total Lines | 52 |
Lines | 29 |
Ratio | 55.77 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
75 | protected function execute(InputInterface $input, OutputInterface $output) |
||
76 | { |
||
77 | parent::execute($input, $output); |
||
78 | |||
79 | $session = $this->mustBeModelManagerSession($this->getSession()); |
||
80 | |||
81 | $this->updateOutput( |
||
82 | $output, |
||
83 | (new StructureGenerator( |
||
84 | $session, |
||
85 | $this->schema, |
||
|
|||
86 | $this->relation, |
||
87 | $this->getPathFile($input->getArgument('config-name'), $this->relation, null, 'AutoStructure', $input->getOption('psr4'), $input->getOption('path-pattern')), |
||
88 | $this->getNamespace($input->getArgument('config-name'), 'AutoStructure', $input->getOption('path-pattern')) |
||
89 | ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions()))) |
||
90 | ); |
||
91 | |||
92 | $pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, 'Model', '', $input->getOption('psr4'), $input->getOption('path-pattern')); |
||
93 | View Code Duplication | if (!file_exists($pathFile) || $input->getOption('force')) { |
|
94 | $this->updateOutput( |
||
95 | $output, |
||
96 | (new ModelGenerator( |
||
97 | $session, |
||
98 | $this->schema, |
||
99 | $this->relation, |
||
100 | $pathFile, |
||
101 | $this->getNamespace($input->getArgument('config-name'), null, $input->getOption('path-pattern')) |
||
102 | ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions()))) |
||
103 | ); |
||
104 | } elseif ($output->isVerbose()) { |
||
105 | $this->writelnSkipFile($output, $pathFile, 'model'); |
||
106 | } |
||
107 | |||
108 | $pathFile = $this->getPathFile($input->getArgument('config-name'), $this->relation, '', '', $input->getOption('psr4'), $input->getOption('path-pattern')); |
||
109 | View Code Duplication | if (!file_exists($pathFile) || $input->getOption('force')) { |
|
110 | $this->updateOutput( |
||
111 | $output, |
||
112 | (new EntityGenerator( |
||
113 | $session, |
||
114 | $this->schema, |
||
115 | $this->relation, |
||
116 | $pathFile, |
||
117 | $this->getNamespace($input->getArgument('config-name'), null, $input->getOption('path-pattern')), |
||
118 | $this->flexible_container |
||
119 | ))->generate(new ParameterHolder(array_merge($input->getArguments(), $input->getOptions()))) |
||
120 | ); |
||
121 | } elseif ($output->isVerbose()) { |
||
122 | $this->writelnSkipFile($output, $pathFile, 'entity'); |
||
123 | } |
||
124 | |||
125 | return 0; |
||
126 | } |
||
127 | |||
151 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.