| Conditions | 4 |
| Paths | 1 |
| Total Lines | 53 |
| Code Lines | 27 |
| 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 |
||
| 67 | public function register(Application $app) |
||
|
|
|||
| 68 | { |
||
| 69 | $app['var_dumper.cloner'] = $app->share(function ($app) { |
||
| 70 | $cloner = new VarCloner(); |
||
| 71 | |||
| 72 | if (isset($app['debug.max_items'])) { |
||
| 73 | $cloner->setMaxItems($app['debug.max_items']); |
||
| 74 | } |
||
| 75 | |||
| 76 | if (isset($app['debug.max_string_length'])) { |
||
| 77 | $cloner->setMaxString($app['debug.max_string_length']); |
||
| 78 | } |
||
| 79 | |||
| 80 | return $cloner; |
||
| 81 | }); |
||
| 82 | |||
| 83 | $app['data_collector.templates'] = array_merge( |
||
| 84 | $app['data_collector.templates'], |
||
| 85 | array(array('dump', '@Debug/Profiler/dump.html.twig')) |
||
| 86 | ); |
||
| 87 | |||
| 88 | $app['data_collector.dump'] = $app->share(function ($app) { |
||
| 89 | return new DumpDataCollector($app['stopwatch'], $app['code.file_link_format']); |
||
| 90 | }); |
||
| 91 | |||
| 92 | $app['data_collectors'] = $app->share($app->extend('data_collectors', function ($collectors, $app) { |
||
| 93 | $collectors['dump'] = $app->share(function ($app) { |
||
| 94 | return $app['data_collector.dump']; |
||
| 95 | }); |
||
| 96 | |||
| 97 | return $collectors; |
||
| 98 | })); |
||
| 99 | |||
| 100 | $app['twig'] = $app->share($app->extend('twig', function ($twig, $app) { |
||
| 101 | if (class_exists('\Symfony\Bridge\Twig\Extension\DumpExtension')) { |
||
| 102 | $twig->addExtension(new DumpExtension($app['var_dumper.cloner'])); |
||
| 103 | } |
||
| 104 | |||
| 105 | return $twig; |
||
| 106 | })); |
||
| 107 | |||
| 108 | $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) { |
||
| 109 | $loader->addPath($app['debug.templates_path'], 'Debug'); |
||
| 110 | |||
| 111 | return $loader; |
||
| 112 | })); |
||
| 113 | |||
| 114 | $app['debug.templates_path'] = function () { |
||
| 115 | $r = new \ReflectionClass('Symfony\Bundle\DebugBundle\DependencyInjection\Configuration'); |
||
| 116 | |||
| 117 | return dirname(dirname($r->getFileName())).'/Resources/views'; |
||
| 118 | }; |
||
| 119 | } |
||
| 120 | |||
| 134 |