| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 30 |
| 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 |
||
| 55 | private static function createContext( $site ) |
||
| 56 | { |
||
| 57 | $ctx = new \Aimeos\MShop\Context(); |
||
| 58 | $aimeos = self::getAimeos(); |
||
| 59 | |||
| 60 | |||
| 61 | $paths = $aimeos->getConfigPaths(); |
||
| 62 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
||
| 63 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
||
| 64 | $local = array( 'resource' => array( 'fs' => array( 'adapter' => 'Standard', 'basedir' => __DIR__ . '/tmp' ) ) ); |
||
| 65 | |||
| 66 | $conf = new \Aimeos\Base\Config\PHPArray( $local, $paths ); |
||
| 67 | $conf = new \Aimeos\Base\Config\Decorator\Memory( $conf ); |
||
| 68 | $conf = new \Aimeos\Base\Config\Decorator\Documentor( $conf, $file ); |
||
| 69 | $ctx->setConfig( $conf ); |
||
| 70 | |||
| 71 | |||
| 72 | $dbm = new \Aimeos\Base\DB\Manager\Standard( $conf->get( 'resource', [] ), 'PDO' ); |
||
| 73 | $ctx->setDatabaseManager( $dbm ); |
||
| 74 | |||
| 75 | |||
| 76 | $fs = new \Aimeos\Base\Filesystem\Manager\Standard( $conf->get( 'resource', [] ) ); |
||
| 77 | $ctx->setFilesystemManager( $fs ); |
||
| 78 | |||
| 79 | |||
| 80 | $mq = new \Aimeos\Base\MQueue\Manager\Standard( $conf->get( 'resource', [] ) ); |
||
| 81 | $ctx->setMessageQueueManager( $mq ); |
||
| 82 | |||
| 83 | |||
| 84 | $logger = new \Aimeos\Base\Logger\File( $site . '.log', \Aimeos\Base\Logger\Iface::DEBUG ); |
||
| 85 | $ctx->setLogger( $logger ); |
||
| 86 | |||
| 87 | |||
| 88 | $cache = new \Aimeos\Base\Cache\None(); |
||
| 89 | $ctx->setCache( $cache ); |
||
| 90 | |||
| 91 | |||
| 92 | $i18n = new \Aimeos\Base\Translation\None( 'de' ); |
||
| 93 | $ctx->setI18n( array( 'de' => $i18n ) ); |
||
| 94 | |||
| 95 | |||
| 96 | $passwd = new \Aimeos\Base\Password\Standard(); |
||
| 97 | $ctx->setPassword( $passwd ); |
||
| 98 | |||
| 99 | |||
| 100 | $session = new \Aimeos\Base\Session\None(); |
||
| 101 | $ctx->setSession( $session ); |
||
| 102 | |||
| 103 | |||
| 104 | $localeManager = \Aimeos\MShop::create( $ctx, 'locale' ); |
||
| 105 | $locale = $localeManager->bootstrap( $site, '', '', false ); |
||
| 106 | $ctx->setLocale( $locale ); |
||
| 107 | |||
| 108 | |||
| 109 | return $ctx->setEditor( 'ai-admin-jqadm' ); |
||
| 110 | } |
||
| 162 |