| Conditions | 3 |
| Paths | 2 |
| Total Lines | 60 |
| Code Lines | 34 |
| 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 |
||
| 102 | $container['oauth2_server.storage.default'] = function (Container $container) { |
||
| 103 | return new Pdo($container['oauth2_server.storage.pdo_connection']); |
||
| 104 | }; |
||
| 105 | $container['oauth2_server.storage.types'] = ['client', 'access_token']; |
||
| 106 | $container['oauth2_server.storage'] = function (Container $container) { |
||
| 107 | $storages = []; |
||
| 108 | foreach ($container['oauth2_server.storage.types'] as $storageType) { |
||
| 109 | $storages[$storageType] = $container['oauth2_server.storage.'.$storageType]; |
||
| 110 | } |
||
| 111 | return $storages; |
||
| 112 | } |
||
| 113 | foreach ($this->storagesTypes as $storageType) { |
||
|
|
|||
| 114 | $container['oauth2_server.storage.'.$storageType] = function (Container $container) { |
||
| 115 | return $container['oauth2_server.storage.default']; |
||
| 116 | }; |
||
| 117 | } |
||
| 118 | $container['oauth2_server.config'] = function () { |
||
| 119 | return ['allow_implicit' => true, 'enforce_state' => false,]; |
||
| 120 | }; |
||
| 121 | $container['oauth2_server.grant_types'] = function () { |
||
| 122 | return []; |
||
| 123 | }; |
||
| 124 | $container['oauth2_server.response_types'] = function () { |
||
| 125 | return []; |
||
| 126 | }; |
||
| 127 | $container['oauth2_server.token_type'] = function () { |
||
| 128 | return null; |
||
| 129 | }; |
||
| 130 | $container['oauth2_server.scope_util'] = function () { |
||
| 131 | return null; |
||
| 132 | }; |
||
| 133 | $container['oauth2_server.client_assertion_type'] = function () { |
||
| 134 | return null; |
||
| 135 | }; |
||
| 136 | return function (Container $container) { |
||
| 137 | return new Server( |
||
| 138 | $container['oauth2_server.storage'], |
||
| 139 | $container['oauth2_server.config'], |
||
| 140 | $container['oauth2_server.grant_types'], |
||
| 141 | $container['oauth2_server.response_types'], |
||
| 142 | $container['oauth2_server.token_type'], |
||
| 143 | $container['oauth2_server.scope_util'], |
||
| 144 | $container['oauth2_server.client_assertion_type'] |
||
| 145 | ); |
||
| 146 | }; |
||
| 147 | } |
||
| 148 | |||
| 149 | private function setupControllers(Container $container) { |
||
| 150 | $container['oauth2_server.controllers_as_service'] = false; |
||
| 151 | $container['oauth2_server.controllers.authorize'] = function (Container $container) { |
||
| 152 | return new Controllers\AuthorizeHandler( |
||
| 153 | $container['oauth2_server']->getAuthorizeController(), |
||
| 154 | $container['oauth2_server.authorize_renderer'] |
||
| 155 | ); |
||
| 156 | }; |
||
| 157 | $container['oauth2_server.controllers.authorize_validator'] = function (Container $container) { |
||
| 158 | return new Controllers\AuthorizeValidator( |
||
| 159 | $container['url_generator'], |
||
| 160 | $container['oauth2_server']->getAuthorizeController(), |
||
| 161 | $container['oauth2_server.authorize_renderer'] |
||
| 162 | ); |
||
| 197 |