| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 49 | private static function createContext( $site ) |
||
| 50 | { |
||
| 51 | $ctx = new \Aimeos\MShop\Context(); |
||
| 52 | $aimeos = self::getAimeos(); |
||
| 53 | |||
| 54 | |||
| 55 | $paths = $aimeos->getConfigPaths(); |
||
| 56 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
||
| 57 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
||
| 58 | |||
| 59 | $conf = new \Aimeos\Base\Config\PHPArray( [], $paths ); |
||
| 60 | $conf = new \Aimeos\Base\Config\Decorator\Memory( $conf ); |
||
| 61 | $conf = new \Aimeos\Base\Config\Decorator\Documentor( $conf, $file ); |
||
| 62 | $ctx->setConfig( $conf ); |
||
| 63 | |||
| 64 | |||
| 65 | $dbm = new \Aimeos\Base\DB\Manager\Standard( $conf->get( 'resource', [] ), 'PDO' ); |
||
| 66 | $ctx->setDatabaseManager( $dbm ); |
||
| 67 | |||
| 68 | |||
| 69 | $fs = new \Aimeos\Base\Filesystem\Manager\Standard( $conf->get( 'resource' ) ); |
||
| 70 | $ctx->setFilesystemManager( $fs ); |
||
| 71 | |||
| 72 | |||
| 73 | $logger = new \Aimeos\Base\Logger\File( 'unittest.log', \Aimeos\Base\Logger\Iface::DEBUG ); |
||
| 74 | $ctx->setLogger( $logger ); |
||
| 75 | |||
| 76 | |||
| 77 | $cache = new \Aimeos\Base\Cache\None(); |
||
| 78 | $ctx->setCache( $cache ); |
||
| 79 | |||
| 80 | |||
| 81 | $passwd = new \Aimeos\Base\Password\Standard(); |
||
| 82 | $ctx->setPassword( $passwd ); |
||
| 83 | |||
| 84 | |||
| 85 | $i18nDE = new \Aimeos\Base\Translation\None( 'de' ); |
||
| 86 | $i18nEN = new \Aimeos\Base\Translation\None( 'en' ); |
||
| 87 | $ctx->setI18n( ['de' => $i18nDE, 'en' => $i18nEN] ); |
||
| 88 | |||
| 89 | |||
| 90 | $mail = new \Aimeos\Base\Mail\Manager\None(); |
||
| 91 | $ctx->setMail( $mail ); |
||
| 92 | |||
| 93 | |||
| 94 | $process = new \Aimeos\Base\Process\None(); |
||
| 95 | $ctx->setProcess( $process ); |
||
| 96 | |||
| 97 | |||
| 98 | $localeManager = \Aimeos\MShop::create( $ctx, 'locale' ); |
||
| 99 | $locale = $localeManager->bootstrap( $site, '', '', false ); |
||
| 100 | $ctx->setLocale( $locale ); |
||
| 101 | |||
| 102 | |||
| 103 | $view = self::createView( $conf ); |
||
| 104 | $ctx->setView( $view ); |
||
| 105 | |||
| 106 | |||
| 107 | return $ctx->setEditor( 'ai-controller-jobs' ); |
||
| 108 | } |
||
| 136 |