Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Code Lines | 27 |
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 declare(strict_types=1); |
||
99 | protected function makeGraphql(): void |
||
100 | { |
||
101 | $listQuery = <<<EOF |
||
102 | query (\$page: Int!) { |
||
103 | {$this->lowerNamePlural}(page: \$page) { |
||
104 | data { |
||
105 | id |
||
106 | TODO |
||
107 | } |
||
108 | |||
109 | paginatorInfo { |
||
110 | currentPage |
||
111 | perPage |
||
112 | total |
||
113 | lastPage |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | EOF; |
||
118 | |||
119 | $this->collection->push( |
||
120 | new GeneratedItem( |
||
121 | GeneratedItem::TYPE_FRONTEND, |
||
122 | $listQuery, |
||
123 | $this->model->getName() . '/queryList.graphql' |
||
124 | ) |
||
125 | ); |
||
126 | |||
127 | $itemQuery = <<<EOF |
||
128 | query (\$id: ID!) { |
||
129 | {$this->lowerName}(id: \$id) { |
||
130 | id |
||
131 | TODO |
||
132 | } |
||
133 | } |
||
134 | EOF; |
||
135 | |||
136 | $this->collection->push( |
||
137 | new GeneratedItem( |
||
138 | GeneratedItem::TYPE_FRONTEND, |
||
139 | $itemQuery, |
||
140 | $this->model->getName() . '/queryItem.graphql' |
||
141 | ) |
||
142 | ); |
||
143 | |||
144 | // TODO: variables |
||
145 | $createMutation = <<<EOF |
||
146 | mutation create(\$name: String!) { |
||
147 | {$this->lowerName}Create(name: \$name) { |
||
148 | TODO |
||
149 | } |
||
150 | } |
||
151 | EOF; |
||
152 | $this->collection->push( |
||
153 | new GeneratedItem( |
||
154 | GeneratedItem::TYPE_FRONTEND, |
||
155 | $createMutation, |
||
156 | $this->model->getName() . '/mutationCreate.graphql' |
||
157 | ) |
||
212 |