| Conditions | 6 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 31 |
| 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 |
||
| 28 | public function register(Container $app) |
||
| 29 | { |
||
| 30 | |||
| 31 | $app['intaro_pinba.script_name_configure.class'] = 'Intaro\PinbaBundle\EventListener\ScriptNameConfigureListener'; |
||
| 32 | $app['intaro_pinba.stopwatch.class'] = 'Intaro\PinbaBundle\Stopwatch\Stopwatch'; |
||
| 33 | $app['intaro_pinba.templating.engine.twig.class'] = 'SilexPinbaProvider\Twig\TimedTwigEnvironment'; |
||
| 34 | $app['intaro_pinba.dbal.logger.class'] = 'Intaro\PinbaBundle\Logger\DbalLogger'; |
||
| 35 | $app['intaro_pinba.server.name'] = 'localhost'; |
||
| 36 | $app['intaro_pinba.script_name_configure.enable'] = true; |
||
| 37 | |||
| 38 | |||
| 39 | $app['intaro_pinba.script_name_configure.listener'] = function () use ($app) { |
||
| 40 | return new $app['intaro_pinba.script_name_configure.class']; |
||
| 41 | }; |
||
| 42 | |||
| 43 | $app['intaro_pinba.stopwatch'] = function () use ($app) { |
||
| 44 | return new $app['intaro_pinba.stopwatch.class']; |
||
| 45 | }; |
||
| 46 | |||
| 47 | $app['doctrine.dbal.logger'] = function () use ($app) { |
||
| 48 | /** |
||
| 49 | * @see \Intaro\PinbaBundle\Logger\DbalLogger |
||
| 50 | */ |
||
| 51 | $className = $app['intaro_pinba.dbal.logger.class']; |
||
| 52 | $host = isset($app["intaro_pinba.doctrine.database_host"]) ? $app["intaro_pinba.doctrine.database_host"] : $app['intaro_pinba.server.name']; |
||
| 53 | return new $className($app["intaro_pinba.stopwatch"], $host); |
||
| 54 | }; |
||
| 55 | |||
| 56 | $app['dbs.config'] = function ($app) { |
||
| 57 | $app['dbs.options.initializer'](); |
||
| 58 | |||
| 59 | $configs = new Container(); |
||
| 60 | foreach ($app['dbs.options'] as $name => $options) { |
||
| 61 | $configs[$name] = new Configuration(); |
||
| 62 | |||
| 63 | if (isset($app['logger']) && class_exists('Intaro\PinbaBundle\Logger\DbalLogger')) { |
||
| 64 | $configs[$name]->setSQLLogger($app['doctrine.dbal.logger']); |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | return $configs; |
||
| 69 | }; |
||
| 70 | |||
| 71 | $app['twig.environment_factory'] = $app->protect(function ($app) { |
||
| 72 | $className = $app['intaro_pinba.templating.engine.twig.class']; |
||
| 73 | $twig = new $className($app['twig.loader'], $app['twig.options']); |
||
| 74 | if($twig instanceof TimedTwigEnvironment) { |
||
| 75 | $twig |
||
| 76 | ->setStopwatch( $app['intaro_pinba.stopwatch']) |
||
| 77 | ->setServerName($app['intaro_pinba.server.name']) |
||
| 78 | ; |
||
| 79 | } |
||
| 80 | return $twig; |
||
| 81 | }); |
||
| 82 | } |
||
| 83 | |||
| 105 | } |