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