| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 28 |
| 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 |
||
| 77 | private static function createContext( $site ) |
||
| 78 | { |
||
| 79 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
||
| 80 | $aimeos = self::getAimeos(); |
||
| 81 | |||
| 82 | |||
| 83 | $paths = $aimeos->getConfigPaths(); |
||
| 84 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
||
| 85 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
||
| 86 | |||
| 87 | $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
||
| 88 | $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
||
| 89 | $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
||
| 90 | $ctx->setConfig( $conf ); |
||
| 91 | |||
| 92 | |||
| 93 | $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
||
| 94 | $ctx->setLogger( $logger ); |
||
| 95 | |||
| 96 | |||
| 97 | $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
||
| 98 | $ctx->setDatabaseManager( $dbm ); |
||
| 99 | |||
| 100 | |||
| 101 | $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf ); |
||
| 102 | $ctx->setFilesystemManager( $fs ); |
||
| 103 | |||
| 104 | |||
| 105 | $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
||
| 106 | $ctx->setMessageQueueManager( $mq ); |
||
| 107 | |||
| 108 | |||
| 109 | $mail = new \Aimeos\MW\Mail\None(); |
||
| 110 | $ctx->setMail( $mail ); |
||
| 111 | |||
| 112 | |||
| 113 | $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
||
| 114 | $ctx->setI18n( array( 'de' => $i18n ) ); |
||
| 115 | |||
| 116 | |||
| 117 | $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
||
| 118 | $locale = $localeManager->bootstrap( $site, 'de', '', false ); |
||
| 119 | $ctx->setLocale( $locale ); |
||
| 120 | |||
| 121 | |||
| 122 | $view = self::createView( $conf ); |
||
| 123 | $ctx->setView( $view ); |
||
| 124 | |||
| 125 | |||
| 126 | $ctx->setEditor( 'core:cntl/jobs' ); |
||
| 127 | |||
| 128 | return $ctx; |
||
| 129 | } |
||
| 167 |