| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 41 |
| 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 |
||
| 32 | public function typeFields(): array |
||
| 33 | { |
||
| 34 | return [ |
||
| 35 | 'id' => [ |
||
| 36 | 'type' => Type::nonNull(Type::id()), |
||
| 37 | 'description' => 'Article identifier', |
||
| 38 | ], |
||
| 39 | 'title' => [ |
||
| 40 | 'type' => Type::nonNull(Type::string()), |
||
| 41 | 'description' => 'Article title', |
||
| 42 | ], |
||
| 43 | 'slug' => [ |
||
| 44 | 'type' => Type::string(), |
||
| 45 | 'description' => 'Article slug (part of url)', |
||
| 46 | ], |
||
| 47 | 'url' => [ |
||
| 48 | 'type' => Type::string(), |
||
| 49 | 'description' => 'Article url', |
||
| 50 | ], |
||
| 51 | 'image' => [ |
||
| 52 | 'type' => Type::nonNull(Type::string()), |
||
| 53 | 'description' => 'Article preview image', |
||
| 54 | ], |
||
| 55 | 'content' => [ |
||
| 56 | 'type' => Type::nonNull(Type::string()), |
||
| 57 | 'description' => 'Article rendered content', |
||
| 58 | ], |
||
| 59 | 'content_source' => [ |
||
| 60 | 'type' => Type::nonNull(Type::string()), |
||
| 61 | 'description' => 'Article content source (original)', |
||
| 62 | ], |
||
| 63 | 'preview' => [ |
||
| 64 | 'type' => Type::string(), |
||
| 65 | 'description' => 'Article content preview', |
||
| 66 | ], |
||
| 67 | 'preview_source' => [ |
||
| 68 | 'type' => Type::string(), |
||
| 69 | 'description' => 'Article content preview (original)', |
||
| 70 | ], |
||
| 71 | 'status' => [ |
||
| 72 | 'type' => Article\Status::class, |
||
| 73 | 'description' => 'Article status', |
||
| 74 | ], |
||
| 75 | 'published_at' => [ |
||
| 76 | 'type' => Type::string(), |
||
| 77 | 'description' => 'Article publishing date and time in RFC3339 format', |
||
| 78 | ], |
||
| 79 | 'user' => [ |
||
| 80 | 'type' => \GraphQL::type('User'), |
||
| 81 | 'description' => 'Article author relation', |
||
| 82 | ], |
||
| 83 | 'tags' => [ |
||
| 84 | 'type' => Type::listOf(\GraphQL::type('Tag')), |
||
| 85 | 'description' => 'Article tags', |
||
| 86 | ], |
||
| 87 | ]; |
||
| 88 | } |
||
| 89 | } |
||
| 90 |