Conditions | 3 |
Paths | 2 |
Total Lines | 88 |
Code Lines | 50 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | 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 |
||
102 | private function OAuth2Server(Container $container) |
||
103 | { |
||
104 | $container['oauth2_server.parameters'] = []; |
||
105 | |||
106 | $container['oauth2_server.storage.default'] = function (Container $container) { |
||
107 | return new Pdo($container['oauth2_server.storage.pdo_connection']); |
||
108 | }; |
||
109 | |||
110 | $container['oauth2_server.storage.types'] = ['client', 'access_token']; |
||
111 | |||
112 | $container['oauth2_server.storage'] = function (Container $container) { |
||
113 | $storages = []; |
||
114 | foreach ($container['oauth2_server.storage.types'] as $storageType) { |
||
115 | $storages[$storageType] = $container['oauth2_server.storage.'.$storageType]; |
||
116 | } |
||
117 | return $storages; |
||
118 | }; |
||
119 | |||
120 | foreach ($this->storagesTypes as $storageType) { |
||
121 | $container['oauth2_server.storage.'.$storageType] = function (Container $container) { |
||
122 | return $container['oauth2_server.storage.default']; |
||
123 | }; |
||
124 | } |
||
125 | |||
126 | $container['oauth2_server.config'] = function () { |
||
127 | return ['allow_implicit' => true, 'enforce_state' => false,]; |
||
128 | }; |
||
129 | |||
130 | $container['oauth2_server.grant_types'] = function () { |
||
131 | return []; |
||
132 | }; |
||
133 | |||
134 | $container['oauth2_server.response_types'] = function () { |
||
135 | return []; |
||
136 | }; |
||
137 | |||
138 | $container['oauth2_server.token_type'] = function () { |
||
139 | return null; |
||
140 | }; |
||
141 | |||
142 | $container['oauth2_server.scope_util'] = function () { |
||
143 | return null; |
||
144 | }; |
||
145 | |||
146 | $container['oauth2_server.client_assertion_type'] = function () { |
||
147 | return null; |
||
148 | }; |
||
149 | |||
150 | $container['oauth2_server.controllers_as_service'] = false; |
||
151 | |||
152 | $container['oauth2_server.controllers.authorize'] = function (Container $container) { |
||
153 | return new Controllers\AuthorizeHandler( |
||
154 | $container['oauth2_server']->getAuthorizeController(), |
||
155 | $container['oauth2_server.authorize_renderer'] |
||
156 | ); |
||
157 | }; |
||
158 | |||
159 | $container['oauth2_server.controllers.authorize_validator'] = function (Container $container) { |
||
160 | return new Controllers\AuthorizeValidator( |
||
161 | $container['url_generator'], |
||
162 | $container['oauth2_server']->getAuthorizeController(), |
||
163 | $container['oauth2_server.authorize_renderer'] |
||
164 | ); |
||
165 | }; |
||
166 | |||
167 | $container['oauth2_server.controllers.authorize_handler'] = function (Container $container) { |
||
168 | return new Controllers\AuthorizeHandler( |
||
169 | $container['oauth2_server']->getAuthorizeController(), |
||
170 | $container['oauth2_server.authorize_renderer'] |
||
171 | ); |
||
172 | }; |
||
173 | |||
174 | $container['oauth2_server.controllers.token'] = function (Container $container) { |
||
175 | return new Controllers\TokenHandler($container['oauth2_server']->getTokenController()); |
||
176 | }; |
||
177 | |||
178 | return function (Container $container) { |
||
179 | return new Server( |
||
180 | $container['oauth2_server.storage'], |
||
181 | $container['oauth2_server.config'], |
||
182 | $container['oauth2_server.grant_types'], |
||
183 | $container['oauth2_server.response_types'], |
||
184 | $container['oauth2_server.token_type'], |
||
185 | $container['oauth2_server.scope_util'], |
||
186 | $container['oauth2_server.client_assertion_type'] |
||
187 | ); |
||
188 | }; |
||
189 | } |
||
190 | |||
215 |