Conditions | 1 |
Paths | 1 |
Total Lines | 67 |
Code Lines | 45 |
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 |
||
74 | public function testMenuTree() { |
||
75 | // TODO: Check cache metadata. |
||
76 | $metadata = $this->defaultCacheMetaData(); |
||
77 | $metadata->addCacheTags([ |
||
78 | 'config:system.menu.test', |
||
79 | ]); |
||
80 | |||
81 | $this->assertResults( |
||
82 | $this->getQueryFromFile('menu.gql'), |
||
83 | [], |
||
84 | [ |
||
85 | 'info' => [ |
||
86 | 'name' => 'Test menu', |
||
87 | 'description' => 'Menu for testing GraphQL menu access.', |
||
88 | ], |
||
89 | 'menu' => [ |
||
90 | 'links' => [ |
||
91 | 0 => [ |
||
92 | 'label' => 'Accessible', |
||
93 | 'route' => [ |
||
94 | 'path' => '/graphql/test/accessible', |
||
95 | 'routed' => TRUE, |
||
96 | ], |
||
97 | 'attribute' => NULL, |
||
98 | 'links' => [ |
||
99 | 0 => [ |
||
100 | 'label' => 'Nested A', |
||
101 | 'attribute' => NULL, |
||
102 | 'route' => [ |
||
103 | 'path' => '/graphql/test/accessible', |
||
104 | 'routed' => TRUE, |
||
105 | ], |
||
106 | ], |
||
107 | 1 => [ |
||
108 | 'label' => 'Nested B', |
||
109 | 'route' => [ |
||
110 | 'path' => '/graphql/test/accessible', |
||
111 | 'routed' => TRUE, |
||
112 | ], |
||
113 | 'attribute' => NULL, |
||
114 | ], |
||
115 | ], |
||
116 | ], |
||
117 | 1 => [ |
||
118 | 'label' => 'Inaccessible', |
||
119 | 'route' => [ |
||
120 | 'path' => '/', |
||
121 | 'routed' => TRUE, |
||
122 | ], |
||
123 | 'attribute' => NULL, |
||
124 | 'links' => [], |
||
125 | ], |
||
126 | 2 => [ |
||
127 | 'label' => 'Drupal', |
||
128 | 'route' => [ |
||
129 | 'path' => 'http://www.drupal.org', |
||
130 | 'routed' => FALSE, |
||
131 | ], |
||
132 | 'attribute' => NULL, |
||
133 | 'links' => [], |
||
134 | ], |
||
135 | ], |
||
136 | ], |
||
137 | ], |
||
138 | $metadata |
||
139 | ); |
||
140 | } |
||
141 | } |
||
142 |