| Conditions | 7 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 161 | protected function macros() |
||
| 162 | { |
||
| 163 | \Aimeos\Upscheme\Up::macro( 'connect', function( array $cfg ) { |
||
| 164 | |||
| 165 | switch( $cfg['adapter'] ) |
||
| 166 | { |
||
| 167 | case 'mysql': $cfg['driver'] = 'pdo_mysql'; break; |
||
| 168 | case 'oracle': $cfg['driver'] = 'pdo_oci'; break; |
||
| 169 | case 'pgsql': $cfg['driver'] = 'pdo_pgsql'; break; |
||
| 170 | case 'sqlsrv': $cfg['driver'] = 'pdo_sqlsrv'; break; |
||
| 171 | default: $cfg['driver'] = $cfg['adapter']; |
||
| 172 | } |
||
| 173 | |||
| 174 | if( isset( $cfg['database'] ) ) { |
||
| 175 | $cfg['dbname'] = $cfg['database']; |
||
| 176 | } |
||
| 177 | |||
| 178 | if( isset( $cfg['username'] ) ) { |
||
| 179 | $cfg['user'] = $cfg['username']; |
||
| 180 | } |
||
| 181 | |||
| 182 | unset( $cfg['adapter'], $cfg['database'], $cfg['username'] ); |
||
| 183 | |||
| 184 | return \Doctrine\DBAL\DriverManager::getConnection( $cfg ); |
||
| 185 | } ); |
||
| 186 | |||
| 187 | |||
| 188 | \Aimeos\Upscheme\Schema\Table::macro( 'startend', function() { |
||
| 189 | $this->datetime( 'start' )->null( true ); |
||
|
|
|||
| 190 | return $this->datetime( 'end' )->null( true ); |
||
| 191 | } ); |
||
| 192 | |||
| 193 | \Aimeos\Upscheme\Schema\Table::macro( 'code', function( string $name = 'code' ) { |
||
| 194 | return $this->string( $name, 64 ) |
||
| 195 | ->opt( 'charset', 'utf8', 'mysql' ) |
||
| 196 | ->opt( 'collation', 'utf8_bin', 'mysql' ) |
||
| 197 | ->default( '' ); |
||
| 198 | } ); |
||
| 199 | |||
| 200 | \Aimeos\Upscheme\Schema\Table::macro( 'type', function( string $name = 'type' ) { |
||
| 201 | return $this->string( $name, 64 ) |
||
| 202 | ->opt( 'charset', 'utf8', 'mysql' ) |
||
| 203 | ->opt( 'collation', 'utf8_bin', 'mysql' ) |
||
| 204 | ->default( '' ); |
||
| 205 | } ); |
||
| 206 | |||
| 207 | \Aimeos\Upscheme\Schema\Table::macro( 'refid', function( string $name = 'refid' ) { |
||
| 208 | return $this->string( $name, 36 ) |
||
| 209 | ->opt( 'charset', 'utf8', 'mysql' ) |
||
| 210 | ->opt( 'collation', 'utf8_bin', 'mysql' ) |
||
| 211 | ->default( '' ); |
||
| 212 | } ); |
||
| 213 | |||
| 214 | \Aimeos\Upscheme\Schema\Table::macro( 'meta', function() { |
||
| 215 | $this->datetime( 'mtime' ); |
||
| 216 | $this->datetime( 'ctime' ); |
||
| 217 | return $this->string( 'editor' ); |
||
| 218 | } ); |
||
| 221 |
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.