Conditions | 22 |
Paths | > 20000 |
Total Lines | 155 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
53 | public function load() |
||
54 | { |
||
55 | |||
56 | // load the configuration instance |
||
57 | $instance = parent::load(); |
||
58 | |||
59 | // set the serial that has been specified as command line option (or the default value) |
||
60 | $instance->setSerial($this->input->getOption(InputOptionKeys::SERIAL)); |
||
61 | |||
62 | // query whether or not an operation name has been specified as command line |
||
63 | // option, if yes override the value from the configuration file |
||
64 | if ($operationName = $this->input->getArgument(InputArgumentKeys::OPERATION_NAME)) { |
||
65 | $instance->setOperationName($operationName); |
||
|
|||
66 | } |
||
67 | |||
68 | // query whether or not a Magento version has been specified as command line |
||
69 | // option, if yes override the value from the configuration file |
||
70 | if ($magentoVersion = $this->input->getOption(InputOptionKeys::MAGENTO_VERSION)) { |
||
71 | $instance->setMagentoVersion($magentoVersion); |
||
72 | } |
||
73 | |||
74 | // query whether or not a directory containing the imported files has been specified as command line |
||
75 | // option, if yes override the value from the configuration file |
||
76 | if ($targetDir = $this->input->getOption(InputOptionKeys::TARGET_DIR)) { |
||
77 | $instance->setTargetDir($targetDir); |
||
78 | } |
||
79 | |||
80 | // query whether or not a directory containing the archived imported files has been specified as command line |
||
81 | // option, if yes override the value from the configuration file |
||
82 | if ($archiveDir = $this->input->getOption(InputOptionKeys::ARCHIVE_DIR)) { |
||
83 | $instance->setArchiveDir($archiveDir); |
||
84 | } |
||
85 | |||
86 | // query whether or not the debug mode has been specified as command line |
||
87 | // option, if yes override the value from the configuration file |
||
88 | if ($archiveArtefacts = $this->input->getOption(InputOptionKeys::ARCHIVE_ARTEFACTS)) { |
||
89 | $instance->setArchiveArtefacts($instance->mapBoolean($archiveArtefacts)); |
||
90 | } |
||
91 | |||
92 | // query whether or not a source date format has been specified as command |
||
93 | // line option, if yes override the value from the configuration file |
||
94 | if ($sourceDateFormat = $this->input->getOption(InputOptionKeys::SOURCE_DATE_FORMAT)) { |
||
95 | $instance->setSourceDateFormat($sourceDateFormat); |
||
96 | } |
||
97 | |||
98 | // query whether or not the debug mode has been specified as command line |
||
99 | // option, if yes override the value from the configuration file |
||
100 | if ($debugMode = $this->input->getOption(InputOptionKeys::DEBUG_MODE)) { |
||
101 | $instance->setDebugMode($instance->mapBoolean($debugMode)); |
||
102 | } |
||
103 | |||
104 | // query whether or not the log level has been specified as command line |
||
105 | // option, if yes override the value from the configuration file |
||
106 | if ($logLevel = $this->input->getOption(InputOptionKeys::LOG_LEVEL)) { |
||
107 | $instance->setLogLevel($logLevel); |
||
108 | } |
||
109 | |||
110 | // query whether or not the single transaction flag has been specified as command line |
||
111 | // option, if yes override the value from the configuration file |
||
112 | if ($singleTransaction = $this->input->getOption(InputOptionKeys::SINGLE_TRANSACTION)) { |
||
113 | $instance->setSingleTransaction($instance->mapBoolean($singleTransaction)); |
||
114 | } |
||
115 | |||
116 | // query whether or not the cache flag has been specified as command line |
||
117 | // option, if yes override the value from the configuration file |
||
118 | if ($cacheEnabled = $this->input->getOption(InputOptionKeys::CACHE_ENABLED)) { |
||
119 | $instance->setCacheEnabled($instance->mapBoolean($cacheEnabled)); |
||
120 | } |
||
121 | |||
122 | // query whether or not we've an valid Magento root directory specified |
||
123 | if ($this->isMagentoRootDir($installationDir = $instance->getInstallationDir())) { |
||
124 | // if yes, add the database configuration |
||
125 | $instance->addDatabase($this->getMagentoDbConnection($installationDir)); |
||
126 | |||
127 | // add the source directory if NOT specified in the configuration file |
||
128 | if (($sourceDir = $instance->getSourceDir()) === null) { |
||
129 | $instance->setSourceDir($sourceDir = sprintf('%s/var/importexport', $installationDir)); |
||
130 | } |
||
131 | |||
132 | // add the target directory if NOT specified in the configuration file |
||
133 | if ($instance->getTargetDir() === null) { |
||
134 | $instance->setTargetDir($sourceDir); |
||
135 | } |
||
136 | } |
||
137 | |||
138 | // query whether or not a DB ID has been specified as command line |
||
139 | // option, if yes override the value from the configuration file |
||
140 | if ($useDbId = $this->input->getOption(InputOptionKeys::USE_DB_ID)) { |
||
141 | $instance->setUseDbId($useDbId); |
||
142 | } else { |
||
143 | // query whether or not a PDO DSN has been specified as command line |
||
144 | // option, if yes override the value from the configuration file |
||
145 | if ($dsn = $this->input->getOption(InputOptionKeys::DB_PDO_DSN)) { |
||
146 | // first REMOVE all other database configurations |
||
147 | $instance->clearDatabases(); |
||
148 | |||
149 | // add the database configuration |
||
150 | $instance->addDatabase( |
||
151 | $this->newDatabaseConfiguration( |
||
152 | $dsn, |
||
153 | $this->input->getOption(InputOptionKeys::DB_USERNAME), |
||
154 | $this->input->getOption(InputOptionKeys::DB_PASSWORD) |
||
155 | ) |
||
156 | ); |
||
157 | } |
||
158 | } |
||
159 | |||
160 | // query whether or not a DB ID has been specified as command line |
||
161 | // option, if yes override the value from the configuration file |
||
162 | if ($tablePrefix = $this->input->getOption(InputOptionKeys::DB_TABLE_PREFIX)) { |
||
163 | $instance->getDatabase()->setTablePrefix($tablePrefix); |
||
164 | } |
||
165 | |||
166 | // extend the plugins with the main configuration instance |
||
167 | /** @var \TechDivision\Import\Cli\Configuration\Subject $subject */ |
||
168 | foreach ($instance->getPlugins() as $plugin) { |
||
169 | // set the configuration instance on the plugin |
||
170 | $plugin->setConfiguration($instance); |
||
171 | |||
172 | // query whether or not the plugin has subjects configured |
||
173 | if ($subjects = $plugin->getSubjects()) { |
||
174 | // extend the plugin's subjects with the main configuration instance |
||
175 | /** @var \TechDivision\Import\Cli\Configuration\Subject $subject */ |
||
176 | foreach ($subjects as $subject) { |
||
177 | // set the configuration instance on the subject |
||
178 | $subject->setConfiguration($instance); |
||
179 | } |
||
180 | } |
||
181 | } |
||
182 | |||
183 | // query whether or not the debug mode is enabled and log level |
||
184 | // has NOT been overwritten with a commandline option |
||
185 | if ($instance->isDebugMode() && !$this->input->getOption(InputOptionKeys::LOG_LEVEL)) { |
||
186 | // set debug log level, if log level has NOT been overwritten on command line |
||
187 | $instance->setLogLevel(LogLevel::DEBUG); |
||
188 | } |
||
189 | |||
190 | // prepend the array with the Magento Edition specific core libraries |
||
191 | $instance->setExtensionLibraries( |
||
192 | array_merge( |
||
193 | $this->getDefaultLibraries($instance->getMagentoEdition()), |
||
194 | $instance->getExtensionLibraries() |
||
195 | ) |
||
196 | ); |
||
197 | |||
198 | // load the extension libraries, if configured |
||
199 | $this->libraryLoader->load($instance); |
||
200 | |||
201 | // register the configured aliases in the DI container, this MUST |
||
202 | // happen after the libraries have been loaded, else it would not |
||
203 | // be possible to override existing aliases |
||
204 | $this->initializeAliases($instance); |
||
205 | |||
206 | // return the initialized configuration instance |
||
207 | return $instance; |
||
208 | } |
||
352 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.