| Conditions | 1 |
| Paths | 1 |
| Total Lines | 60 |
| Code Lines | 51 |
| 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 |
||
| 23 | public function config(): array |
||
| 24 | { |
||
| 25 | return [ |
||
| 26 | 'class' => Post::class, |
||
| 27 | 'envelope' => 'graphql.shortcode_media', |
||
| 28 | 'properties' => [ |
||
| 29 | 'id' => 'id', |
||
| 30 | 'shortcode' => 'shortcode', |
||
| 31 | 'url' => 'display_url', |
||
| 32 | 'caption' => 'edge_media_to_caption.edges.0.node.text', |
||
| 33 | 'likes' => 'edge_media_preview_like.count', |
||
| 34 | 'comments' => 'edge_media_preview_comment.count', |
||
| 35 | 'takenAt' => 'taken_at_timestamp', |
||
| 36 | 'isVideo' => 'is_video', |
||
| 37 | 'videoViews' => 'video_view_count', |
||
| 38 | 'videoUrl' => 'video_url', |
||
| 39 | 'typename' => '__typename', |
||
| 40 | 'accessibilityCaption' => 'accessibility_caption', |
||
| 41 | ], |
||
| 42 | 'relations' => [ |
||
| 43 | 'account' => [ |
||
| 44 | 'class' => Account::class, |
||
| 45 | 'envelope' => 'owner', //related to parent map |
||
| 46 | 'properties' => [ |
||
| 47 | 'id' => 'id', |
||
| 48 | 'username' => 'username', |
||
| 49 | 'profilePicUrl' => 'profile_pic_url', |
||
| 50 | 'fullName' => 'full_name', |
||
| 51 | 'isPrivate' => 'is_private', |
||
| 52 | ], |
||
| 53 | ], |
||
| 54 | 'location' => [ |
||
| 55 | 'class' => Location::class, |
||
| 56 | 'envelope' => 'location', |
||
| 57 | 'properties' => [ |
||
| 58 | 'id' => 'id', |
||
| 59 | 'hasPublicPage' => 'has_public_page', |
||
| 60 | 'name' => 'name', |
||
| 61 | 'slug' => 'slug', |
||
| 62 | 'addressJson' => 'address_json', |
||
| 63 | ], |
||
| 64 | ], |
||
| 65 | 'sponsor' => [ |
||
| 66 | 'class' => Account::class, |
||
| 67 | 'envelope' => 'edge_media_to_sponsor_user.edges.0.node.sponsor', //related to parent map |
||
| 68 | 'properties' => [ |
||
| 69 | 'id' => 'id', |
||
| 70 | 'username' => 'username', |
||
| 71 | ], |
||
| 72 | ], |
||
| 73 | 'tagged' => [ |
||
| 74 | 'multiple' => true, |
||
| 75 | 'class' => Account::class, |
||
| 76 | 'envelope' => 'edge_media_to_tagged_user.edges', |
||
| 77 | 'properties' => [ |
||
| 78 | 'id' => 'node.user.id', |
||
| 79 | 'username' => 'node.user.username', |
||
| 80 | 'profilePicUrl' => 'node.user.profile_pic_url', |
||
| 81 | 'fullName' => 'node.user.full_name', |
||
| 82 | 'isVerified' => 'node.user.is_verified', |
||
| 83 | ], |
||
| 88 | } |