| Conditions | 7 |
| Paths | 1 |
| Total Lines | 73 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 169 | protected function macros() |
||
| 170 | { |
||
| 171 | \Aimeos\Upscheme\Up::macro( 'connect', function( array $cfg ) { |
||
| 172 | |||
| 173 | switch( $cfg['adapter'] ) |
||
| 174 | { |
||
| 175 | case 'mysql': $cfg['driver'] = 'pdo_mysql'; break; |
||
| 176 | case 'oracle': $cfg['driver'] = 'pdo_oci'; break; |
||
| 177 | case 'pgsql': $cfg['driver'] = 'pdo_pgsql'; break; |
||
| 178 | case 'sqlsrv': $cfg['driver'] = 'pdo_sqlsrv'; break; |
||
| 179 | default: $cfg['driver'] = $cfg['adapter']; |
||
| 180 | } |
||
| 181 | |||
| 182 | if( isset( $cfg['database'] ) ) { |
||
| 183 | $cfg['dbname'] = $cfg['database']; |
||
| 184 | } |
||
| 185 | |||
| 186 | if( isset( $cfg['username'] ) ) { |
||
| 187 | $cfg['user'] = $cfg['username']; |
||
| 188 | } |
||
| 189 | |||
| 190 | unset( $cfg['adapter'], $cfg['database'], $cfg['username'] ); |
||
| 191 | |||
| 192 | return \Doctrine\DBAL\DriverManager::getConnection( $cfg ); |
||
| 193 | } ); |
||
| 194 | |||
| 195 | |||
| 196 | $codelen = $this->config['codelength'] ?? 64; |
||
| 197 | |||
| 198 | \Aimeos\Upscheme\Schema\Table::macro( 'startend', function() { |
||
| 199 | $this->datetime( 'start' )->null( true ); |
||
|
|
|||
| 200 | return $this->datetime( 'end' )->null( true ); |
||
| 201 | } ); |
||
| 202 | |||
| 203 | \Aimeos\Upscheme\Schema\Table::macro( 'code', function( string $name = 'code' ) use ( $codelen ) { |
||
| 204 | return $this->string( $name, $codelen ) |
||
| 205 | ->opt( 'charset', 'utf8mb4', 'mysql' ) |
||
| 206 | ->opt( 'collation', 'utf8mb4_bin', 'mysql' ) |
||
| 207 | ->default( '' ); |
||
| 208 | } ); |
||
| 209 | |||
| 210 | \Aimeos\Upscheme\Schema\Table::macro( 'config', function( string $name = 'config' ) { |
||
| 211 | return $this->text( $name ) |
||
| 212 | ->opt( 'charset', 'utf8mb4', 'mysql' ) |
||
| 213 | ->opt( 'collation', 'utf8mb4_general_ci', 'mysql' ) |
||
| 214 | ->null( true ); |
||
| 215 | } ); |
||
| 216 | |||
| 217 | \Aimeos\Upscheme\Schema\Table::macro( 'type', function( string $name = 'type' ) use ( $codelen ) { |
||
| 218 | return $this->string( $name, $codelen ) |
||
| 219 | ->opt( 'charset', 'utf8mb4', 'mysql' ) |
||
| 220 | ->opt( 'collation', 'utf8mb4_bin', 'mysql' ) |
||
| 221 | ->default( '' ); |
||
| 222 | } ); |
||
| 223 | |||
| 224 | \Aimeos\Upscheme\Schema\Table::macro( 'refid', function( string $name = 'refid' ) { |
||
| 225 | return $this->string( $name, 36 ) |
||
| 226 | ->opt( 'charset', 'utf8mb4', 'mysql' ) |
||
| 227 | ->opt( 'collation', 'utf8mb4_bin', 'mysql' ) |
||
| 228 | ->default( '' ); |
||
| 229 | } ); |
||
| 230 | |||
| 231 | \Aimeos\Upscheme\Schema\Table::macro( 'i18n', function( string $name = 'i18n' ) { |
||
| 232 | return $this->text( $name ) |
||
| 233 | ->opt( 'charset', 'utf8mb4', 'mysql' ) |
||
| 234 | ->opt( 'collation', 'utf8mb4_bin', 'mysql' ) |
||
| 235 | ->null( true ); |
||
| 236 | } ); |
||
| 237 | |||
| 238 | \Aimeos\Upscheme\Schema\Table::macro( 'meta', function() { |
||
| 239 | $this->datetime( 'mtime' ); |
||
| 240 | $this->datetime( 'ctime' ); |
||
| 241 | return $this->string( 'editor' ); |
||
| 242 | } ); |
||
| 245 |
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.