Conditions | 17 |
Paths | 256 |
Total Lines | 44 |
Code Lines | 24 |
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 |
||
194 | protected function getConnectionParameters () : array |
||
195 | { |
||
196 | $this->connectionParameters = array(); |
||
197 | |||
198 | $this->connectionParameters["driver"] = $this->driver; |
||
199 | $this->connectionParameters["user"] = $this->user; |
||
200 | $this->connectionParameters["password"] = $this->password; |
||
201 | $this->connectionParameters["host"] = $this->host; |
||
202 | $this->connectionParameters["port"] = $this->port; |
||
203 | $this->connectionParameters["dbname"] = $this->dbName; |
||
204 | |||
205 | if ( isset( $this->charset ) && $this->charset !== "" ) { |
||
206 | $this->connectionParameters["charset"] = $this->charset; |
||
207 | } |
||
208 | |||
209 | if ( isset( $this->defaultDatabaseName ) && $this->defaultDatabaseName !== "" ) { |
||
210 | $this->connectionParameters["default_dbname"] = $this->defaultDatabaseName; |
||
211 | } |
||
212 | |||
213 | if ( isset( $this->sslMode ) && $this->sslMode !== "" ) { |
||
214 | $this->connectionParameters["sslmode"] = $this->sslMode; |
||
215 | } |
||
216 | |||
217 | if ( isset( $this->sslRootCert ) && $this->sslRootCert !== "" ) { |
||
218 | $this->connectionParameters["sslrootcert"] = $this->sslRootCert; |
||
219 | } |
||
220 | |||
221 | if ( isset( $this->sslCert ) && $this->sslCert !== "" ) { |
||
222 | $this->connectionParameters["sslcert"] = $this->sslCert; |
||
223 | } |
||
224 | |||
225 | if ( isset( $this->sslKey ) && $this->sslKey !== "" ) { |
||
226 | $this->connectionParameters["sslkey"] = $this->sslKey; |
||
227 | } |
||
228 | |||
229 | if ( isset( $this->sslCrl ) && $this->sslCrl !== "" ) { |
||
230 | $this->connectionParameters["sslcrl"] = $this->sslCrl; |
||
231 | } |
||
232 | |||
233 | if ( isset( $this->applicationName ) && $this->applicationName !== "" ) { |
||
234 | $this->connectionParameters["application_name"] = $this->applicationName; |
||
235 | } |
||
236 | |||
237 | return $this->connectionParameters; |
||
238 | } |
||
240 |