Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
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(); |
||
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 | $cache = new \Aimeos\MW\Cache\None(); |
||
89 | $ctx->setCache( $cache ); |
||
90 | |||
91 | |||
92 | $session = new \Aimeos\MW\Session\None(); |
||
93 | $ctx->setSession( $session ); |
||
94 | |||
95 | |||
96 | $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
||
97 | $ctx->setI18n( array( 'de' => $i18n ) ); |
||
98 | |||
99 | |||
100 | $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
||
101 | $locale = $localeManager->bootstrap( $site, 'de', '', false ); |
||
102 | $ctx->setLocale( $locale ); |
||
103 | |||
104 | |||
105 | $view = self::createView( $conf ); |
||
106 | $ctx->setView( $view ); |
||
107 | |||
108 | |||
109 | $ctx->setEditor( 'core:controller/jobs' ); |
||
110 | |||
111 | return $ctx; |
||
112 | } |
||
144 |