| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 53 |
| 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 |
||
| 50 | public function __construct() { |
||
| 51 | parent::__construct('passman'); |
||
| 52 | $container = $this->getContainer(); |
||
| 53 | // Allow automatic DI for the View, until we migrated to Nodes API |
||
| 54 | $container->registerService(View::class, function () { |
||
| 55 | return new View(''); |
||
| 56 | }, false); |
||
| 57 | $container->registerService('isCLI', function () { |
||
| 58 | return \OC::$CLI; |
||
| 59 | }); |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Middleware |
||
| 63 | */ |
||
| 64 | $container->registerService('ShareMiddleware', function ($c) { |
||
| 65 | return new ShareMiddleware($c->query('SettingsService')); |
||
| 66 | }); |
||
| 67 | $container->registerMiddleware('ShareMiddleware'); |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Controllers |
||
| 71 | */ |
||
| 72 | $container->registerService('ShareController', function ($c) { |
||
| 73 | $container = $this->getContainer(); |
||
| 74 | $server = $container->getServer(); |
||
| 75 | return new ShareController( |
||
| 76 | $c->query('AppName'), |
||
| 77 | $c->query('Request'), |
||
| 78 | $server->getUserSession()->getUser(), |
||
| 79 | $server->getGroupManager(), |
||
| 80 | $server->getUserManager(), |
||
| 81 | $c->query('ActivityService'), |
||
| 82 | $c->query('VaultService'), |
||
| 83 | $c->query('ShareService'), |
||
| 84 | $c->query('CredentialService'), |
||
| 85 | $c->query('NotificationService'), |
||
| 86 | $c->query('FileService'), |
||
| 87 | $c->query('SettingsService') |
||
| 88 | ); |
||
| 89 | }); |
||
| 90 | |||
| 91 | |||
| 92 | /** Cron **/ |
||
| 93 | $container->registerService('CronService', function ($c) { |
||
| 94 | return new CronService( |
||
| 95 | $c->query('CredentialService'), |
||
| 96 | $c->query('Logger'), |
||
| 97 | $c->query('Utils'), |
||
| 98 | $c->query('NotificationService'), |
||
| 99 | $c->query('ActivityService'), |
||
| 100 | $c->query('IDBConnection') |
||
| 101 | ); |
||
| 102 | }); |
||
| 103 | |||
| 104 | $container->registerService('Db', function () { |
||
| 105 | return new Db(); |
||
| 106 | }); |
||
| 107 | |||
| 108 | $container->registerService('Logger', function ($c) { |
||
| 109 | return $c->query('ServerContainer')->getLogger(); |
||
| 110 | }); |
||
| 111 | |||
| 112 | // Aliases for the controllers so we can use the automatic DI |
||
| 113 | $container->registerAlias('CredentialController', CredentialController::class); |
||
| 114 | $container->registerAlias('PageController', PageController::class); |
||
| 115 | $container->registerAlias('VaultController', VaultController::class); |
||
| 116 | $container->registerAlias('VaultController', VaultController::class); |
||
| 117 | $container->registerAlias('CredentialService', CredentialService::class); |
||
| 118 | $container->registerAlias('NotificationService', NotificationService::class); |
||
| 119 | $container->registerAlias('ActivityService', ActivityService::class); |
||
| 120 | $container->registerAlias('VaultService', VaultService::class); |
||
| 121 | $container->registerAlias('FileService', FileService::class); |
||
| 122 | $container->registerAlias('ShareService', ShareService::class); |
||
| 123 | $container->registerAlias('Utils', Utils::class); |
||
| 124 | $container->registerAlias('IDBConnection', IDBConnection::class); |
||
| 125 | $container->registerAlias('IConfig', IConfig::class); |
||
| 126 | $container->registerAlias('SettingsService', SettingsService::class); |
||
| 127 | } |
||
| 128 | |||
| 154 | } |