| Conditions | 1 |
| Paths | 1 |
| Total Lines | 59 |
| Code Lines | 35 |
| 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 |
||
| 15 | public function testContainerInjected(): void |
||
| 16 | { |
||
| 17 | $container = $this->getContainer(); |
||
| 18 | |||
| 19 | $apiGroup = Group::create( |
||
| 20 | '/api', |
||
| 21 | [ |
||
| 22 | Route::get('/info')->name('api-info'), |
||
| 23 | Group::create( |
||
| 24 | '/v1', |
||
| 25 | [ |
||
| 26 | Route::get('/user')->name('api-v1-user/index'), |
||
| 27 | Route::get('/user/{id}')->name('api-v1-user/view'), |
||
| 28 | Group::create( |
||
| 29 | '/news', |
||
| 30 | [ |
||
| 31 | Route::get('/post')->name('api-v1-news-post/index'), |
||
| 32 | Route::get('/post/{id}')->name('api-v1-news-post/view'), |
||
| 33 | ] |
||
| 34 | ), |
||
| 35 | Group::create( |
||
| 36 | '/blog', |
||
| 37 | [ |
||
| 38 | Route::get('/post')->name('api-v1-blog-post/index'), |
||
| 39 | Route::get('/post/{id}')->name('api-v1-blog-post/view'), |
||
| 40 | ] |
||
| 41 | ), |
||
| 42 | Route::get('/note')->name('api-v1-note/index'), |
||
| 43 | Route::get('/note/{id}')->name('api-v1-note/view'), |
||
| 44 | ] |
||
| 45 | ), |
||
| 46 | Group::create( |
||
| 47 | '/v2', |
||
| 48 | [ |
||
| 49 | Route::get('/user')->name('api-v2-user/index'), |
||
| 50 | Route::get('/user/{id}')->name('api-v2-user/view'), |
||
| 51 | Group::create( |
||
| 52 | '/news', |
||
| 53 | [ |
||
| 54 | Route::get('/post')->name('api-v2-news-post/index'), |
||
| 55 | Route::get('/post/{id}')->name('api-v2-news-post/view'), |
||
| 56 | ] |
||
| 57 | ), |
||
| 58 | Group::create( |
||
| 59 | '/blog', |
||
| 60 | [ |
||
| 61 | Route::get('/post')->name('api-v2-blog-post/index'), |
||
| 62 | Route::get('/post/{id}')->name('api-v2-blog-post/view'), |
||
| 63 | ] |
||
| 64 | ), |
||
| 65 | Route::get('/note')->name('api-v2-note/index'), |
||
| 66 | Route::get('/note/{id}')->name('api-v2-note/view'), |
||
| 67 | ] |
||
| 68 | ) |
||
| 69 | ], $container); |
||
| 70 | |||
| 71 | $items = $apiGroup->getItems(); |
||
| 72 | |||
| 73 | $this->assertAllRoutesAndGroupsHaveContainer($items); |
||
| 74 | } |
||
| 93 |