Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 44 |
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 |
||
43 | public function config(): array |
||
44 | { |
||
45 | return [ |
||
46 | 'class' => MediaCollection::class, |
||
47 | 'envelope' => $this->envelope, |
||
48 | 'properties' => [ |
||
49 | 'count' => 'count', |
||
50 | ], |
||
51 | 'relations' => [ |
||
52 | 'posts' => [ |
||
53 | 'multiple' => true, |
||
54 | 'class' => Post::class, |
||
55 | 'envelope' => 'edges', |
||
56 | 'properties' => [ |
||
57 | 'id' => 'node.id', |
||
58 | 'shortcode' => 'node.shortcode', |
||
59 | 'url' => 'node.display_url', |
||
60 | 'caption' => 'node.edge_media_to_caption.edges.0.node.text', |
||
61 | 'likes' => 'node.edge_media_preview_like.count', |
||
62 | 'comments' => 'node.edge_media_to_comment.count', |
||
63 | 'takenAt' => 'node.taken_at_timestamp', |
||
64 | 'isVideo' => 'node.is_video', |
||
65 | 'videoViews' => 'node.video_view_count', |
||
66 | 'videoUrl' => 'node.video_url', |
||
67 | 'typename' => 'node.__typename', |
||
68 | 'accessibilityCaption' => 'node.accessibility_caption', |
||
69 | ], |
||
70 | 'relations' => [ |
||
71 | 'account' => [ |
||
72 | 'class' => Account::class, |
||
73 | 'envelope' => 'node.owner', |
||
74 | 'properties' => [ |
||
75 | 'id' => 'id', |
||
76 | 'username' => 'username', |
||
77 | ], |
||
78 | ], |
||
79 | 'location' => [ |
||
80 | 'class' => Location::class, |
||
81 | 'envelope' => 'node.location', |
||
82 | 'properties' => [ |
||
83 | 'id' => 'id', |
||
84 | 'hasPublicPage' => 'has_public_page', |
||
85 | 'name' => 'name', |
||
86 | 'slug' => 'slug', |
||
87 | ], |
||
88 | ], |
||
89 | ], |
||
90 | ], |
||
91 | 'pageInfo' => [ |
||
92 | 'class' => PageInfo::class, |
||
93 | 'envelope' => 'page_info', |
||
94 | 'properties' => [ |
||
95 | 'hasNextPage' => 'has_next_page', |
||
96 | 'endCursor' => 'end_cursor', |
||
97 | ], |
||
102 | } |