Conditions | 7 |
Paths | 21 |
Total Lines | 59 |
Code Lines | 34 |
Lines | 11 |
Ratio | 18.64 % |
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 |
||
114 | protected function start() |
||
115 | { |
||
116 | $pluginCode = $this->paramList['pluginCode']['value']; |
||
117 | |||
118 | $codes = $this->getPluginCodes(); |
||
119 | if (!in_array($pluginCode, $codes)) { |
||
120 | $this->exitGenerator('<error>This plugin code does not exist.</error>'); |
||
121 | |||
122 | return; |
||
123 | } |
||
124 | |||
125 | $fsList = array( |
||
126 | 'dir' => array(), |
||
127 | 'file' => array(), |
||
128 | ); |
||
129 | |||
130 | $pluginCode = $this->paramList['pluginCode']['value']; |
||
131 | $ymlList = $this->paramList['ymlList']['value']; |
||
132 | |||
133 | $codePath = $this->app['config']['root_dir'].'/app/Plugin/'.$pluginCode; |
||
134 | |||
135 | $dirList = array('Entity', 'Repository', 'Resource/doctrine/migration'); |
||
136 | View Code Duplication | foreach ($dirList as $dirName) { |
|
137 | $dirPath = $codePath.'/'.$dirName; |
||
138 | if (!is_dir($dirPath)) { |
||
139 | mkdir($dirPath); |
||
140 | } |
||
141 | if (is_dir($dirPath)) { |
||
142 | $fsList['dir'][$dirPath] = true; |
||
143 | } else { |
||
144 | $fsList['dir'][$dirPath] = false; |
||
145 | } |
||
146 | } |
||
147 | |||
148 | // metadataの設定 |
||
149 | $classNames = array(); |
||
150 | foreach ($ymlList as $item) { |
||
151 | $yml = Yaml::parse(file_get_contents($item)); |
||
152 | $classNames[] = key($yml); |
||
153 | } |
||
154 | |||
155 | $YamlDriver = new YamlDriver(array($codePath.'/Resource/doctrine')); |
||
156 | $metadatas = array(); |
||
157 | foreach ($classNames as $className) { |
||
158 | $ClassMetadataInfo = new ClassMetadataInfo($className); |
||
159 | $YamlDriver->loadMetadataForClass($className, $ClassMetadataInfo); |
||
160 | $metadatas[] = $ClassMetadataInfo; |
||
161 | } |
||
162 | |||
163 | // Entity、Repositoryファイルの作成 |
||
164 | $this->generateEntities($metadatas, $fsList); |
||
165 | |||
166 | // migrationファイルの作成 |
||
167 | $this->generateMigration($metadatas, $fsList, $pluginCode, $codePath); |
||
168 | |||
169 | // 完了メッセージ |
||
170 | $this->completeMessage($fsList); |
||
171 | |||
172 | } |
||
173 | } |
||
174 |