| Conditions | 2 |
| Paths | 1 |
| Total Lines | 71 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| Bugs | 3 | Features | 1 |
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 |
||
| 36 | public function __construct (array $urlParams=array()) { |
||
| 37 | parent::__construct('tasks', $urlParams); |
||
| 38 | |||
| 39 | $container = $this->getContainer(); |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Controllers |
||
| 43 | */ |
||
| 44 | $container->registerService('PageController', function(IAppContainer $c) { |
||
| 45 | return new PageController( |
||
| 46 | $c->query('AppName'), |
||
| 47 | $c->query('Request'), |
||
| 48 | $c->query('UserId'), |
||
| 49 | $c->query('ServerContainer')->getConfig() |
||
| 50 | ); |
||
| 51 | }); |
||
| 52 | |||
| 53 | $container->registerService('CollectionsController', function(IAppContainer $c) { |
||
| 54 | return new CollectionsController( |
||
| 55 | $c->query('AppName'), |
||
| 56 | $c->query('Request'), |
||
| 57 | $c->query('CollectionsService') |
||
| 58 | ); |
||
| 59 | }); |
||
| 60 | |||
| 61 | $container->registerService('SettingsController', function(IAppContainer $c) { |
||
| 62 | return new SettingsController( |
||
| 63 | $c->query('AppName'), |
||
| 64 | $c->query('Request'), |
||
| 65 | $c->query('SettingsService') |
||
| 66 | ); |
||
| 67 | }); |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Services |
||
| 71 | */ |
||
| 72 | |||
| 73 | $container->registerService('CollectionsService', function(IAppContainer $c) { |
||
| 74 | return new CollectionsService( |
||
| 75 | $c->query('UserId'), |
||
| 76 | $c->query('L10N'), |
||
| 77 | $c->query('Settings'), |
||
| 78 | $c->query('AppName') |
||
| 79 | ); |
||
| 80 | }); |
||
| 81 | |||
| 82 | $container->registerService('SettingsService', function(IAppContainer $c) { |
||
| 83 | return new SettingsService( |
||
| 84 | $c->query('UserId'), |
||
| 85 | $c->query('Settings'), |
||
| 86 | $c->query('AppName') |
||
| 87 | ); |
||
| 88 | }); |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Core |
||
| 92 | */ |
||
| 93 | $container->registerService('UserId', function(IAppContainer $c) { |
||
| 94 | $user = $c->query('ServerContainer')->getUserSession()->getUser(); |
||
| 95 | |||
| 96 | return ($user) ? $user->getUID() : ''; |
||
| 97 | }); |
||
| 98 | |||
| 99 | $container->registerService('L10N', function(IAppContainer $c) { |
||
| 100 | return $c->query('ServerContainer')->getL10N($c->query('AppName')); |
||
| 101 | }); |
||
| 102 | |||
| 103 | $container->registerService('Settings', function(IAppContainer $c) { |
||
| 104 | return $c->query('ServerContainer')->getConfig(); |
||
| 105 | }); |
||
| 106 | } |
||
| 107 | } |
||
| 108 |