| Conditions | 1 |
| Paths | 1 |
| Total Lines | 127 |
| 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 |
||
| 63 | public function testExample(): void { |
||
| 64 | $request = new TestRequest(); |
||
| 65 | $response = $request->get(array('id'=>'example'), '/doku.php'); |
||
| 66 | |||
| 67 | // save the response html |
||
| 68 | //$handle=fopen('/tmp/data.html', 'w'); |
||
| 69 | //fwrite($handle, $response->getContent()); |
||
| 70 | //fclose($handle); |
||
| 71 | |||
| 72 | //print_r($response); |
||
| 73 | $this->assertTrue(strpos($response->getContent(), |
||
| 74 | '<h1 class="sectionedit1" id="yalist_example">yalist example</h1> |
||
| 75 | <div class="level1"> |
||
| 76 | <ol> |
||
| 77 | <li class="level1"><div class="li"> |
||
| 78 | Ordered list item 1 |
||
| 79 | </div></li> |
||
| 80 | <li class="level1"><div class="li"> |
||
| 81 | Ordered list item 2 |
||
| 82 | </div></li> |
||
| 83 | <li class="level1"><div class="li"> |
||
| 84 | <p> |
||
| 85 | Ordered list item 3… |
||
| 86 | </p><p> |
||
| 87 | … in multiple paragraphs |
||
| 88 | </p> |
||
| 89 | </div></li> |
||
| 90 | <li class="level1"><div class="li"> |
||
| 91 | Ordered list item 4 |
||
| 92 | </div></li> |
||
| 93 | </ol> |
||
| 94 | |||
| 95 | <ul> |
||
| 96 | <li class="level1"><div class="li"> |
||
| 97 | Unordered list item |
||
| 98 | </div></li> |
||
| 99 | <li class="level1"><div class="li"> |
||
| 100 | <p> |
||
| 101 | Unordered list item… |
||
| 102 | </p><p> |
||
| 103 | … in multiple paragraphs |
||
| 104 | </p> |
||
| 105 | </div></li> |
||
| 106 | </ul> |
||
| 107 | |||
| 108 | <ol> |
||
| 109 | <li class="level1"><div class="li"> |
||
| 110 | Ordered list, first level |
||
| 111 | </div><ol> |
||
| 112 | <li class="level2"><div class="li"> |
||
| 113 | Second level |
||
| 114 | </div><ol> |
||
| 115 | <li class="level3"><div class="li"> |
||
| 116 | Third level |
||
| 117 | </div><ol> |
||
| 118 | <li class="level4"><div class="li"> |
||
| 119 | Fourth level |
||
| 120 | </div></li> |
||
| 121 | </ol> |
||
| 122 | </li> |
||
| 123 | </ol> |
||
| 124 | </li> |
||
| 125 | <li class="level2"><div class="li"> |
||
| 126 | <p> |
||
| 127 | Back to second level |
||
| 128 | </p> |
||
| 129 | </div><ol> |
||
| 130 | <li class="level3"><div class="li"> |
||
| 131 | <em>Second?! What happened to third?</em> |
||
| 132 | </div></li> |
||
| 133 | </ol> |
||
| 134 | <div class="li"> |
||
| 135 | <p> |
||
| 136 | <em>Quiet, you.</em> |
||
| 137 | </p> |
||
| 138 | </div></li> |
||
| 139 | </ol> |
||
| 140 | </li> |
||
| 141 | <li class="level1"><div class="li"> |
||
| 142 | Back to first level |
||
| 143 | </div></li> |
||
| 144 | <li class="level1"><div class="li"> |
||
| 145 | Still at first level |
||
| 146 | </div></li> |
||
| 147 | </ol> |
||
| 148 | |||
| 149 | <dl> |
||
| 150 | <dt class="level1"><span class="dt"> Definition list</span></dt> |
||
| 151 | <dd class="level1"><div class="dd"> |
||
| 152 | Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content. [Source: <abbr title="World Wide Web Consortium">W3C</abbr>] |
||
| 153 | </div></dd> |
||
| 154 | <dt class="level1"><span class="dt"> Definition list w/ multiple paragraphs</span></dt> |
||
| 155 | <dd class="level1"><div class="dd"> |
||
| 156 | <p> |
||
| 157 | The style sheet provided with this plugin will render these paragraphs… |
||
| 158 | </p><p> |
||
| 159 | … to the left of the term being defined. |
||
| 160 | </p> |
||
| 161 | </div><dl> |
||
| 162 | <dt class="level2"><span class="dt"> Definition list w/ multiple “paragraphs”</span></dt> |
||
| 163 | <dd class="level2"><div class="dd"> |
||
| 164 | Another way to separate blocks of text in a definition… |
||
| 165 | </div></dd> |
||
| 166 | <dd class="level2"><div class="dd"> |
||
| 167 | … is to simply have multiple definitions for a term (or group of terms). |
||
| 168 | </div></dd> |
||
| 169 | </dl> |
||
| 170 | </dd> |
||
| 171 | </dl> |
||
| 172 | |||
| 173 | <dl> |
||
| 174 | <dd class="level1"><div class="dd"> |
||
| 175 | This definition list has DD tags without any preceding DT tags. |
||
| 176 | </div></dd> |
||
| 177 | <dd class="level1"><div class="dd"> |
||
| 178 | Hey, it's legal XHTML. |
||
| 179 | </div></dd> |
||
| 180 | <dt class="level1"><span class="dt"> Just like DT tags without following DD tags.</span></dt> |
||
| 181 | <dt class="level1"><span class="dt">? But DT tags can't contain paragraphs. That would <em class="u">not</em> be legal XHTML.</span></dt> |
||
| 182 | </dl> |
||
| 183 | |||
| 184 | <pre class="code">.. If you try, the result will be rendered oddly.</pre> |
||
| 185 | |||
| 186 | </div>') !== false, |
||
| 187 | 'expected html snippet was not in the output' |
||
| 188 | ); |
||
| 189 | } |
||
| 190 | } |
||
| 191 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.