| Conditions | 1 |
| Paths | 1 |
| Total Lines | 129 |
| 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 | print_r($response); |
||
| 68 | //file_get_contents("example.html"); |
||
| 69 | |||
| 70 | //$handle=fopen('/tmp/data.html', 'w'); |
||
| 71 | //fwrite($handle, $response->getContent()); |
||
| 72 | //close($handle); |
||
| 73 | |||
| 74 | //print_r($response);\ |
||
| 75 | $this->assertTrue(strpos($response->getContent(), |
||
| 76 | '<h1 class="sectionedit1" id="yalist_example">yalist example</h1> |
||
| 77 | <div class="level1"> |
||
| 78 | <ol> |
||
| 79 | <li class="level1"><div class="li"> |
||
| 80 | Ordered list item 1 |
||
| 81 | </div></li> |
||
| 82 | <li class="level1"><div class="li"> |
||
| 83 | Ordered list item 2 |
||
| 84 | </div></li> |
||
| 85 | <li class="level1"><div class="li"> |
||
| 86 | <p> |
||
| 87 | Ordered list item 3… |
||
| 88 | </p><p> |
||
| 89 | … in multiple paragraphs |
||
| 90 | </p> |
||
| 91 | </div></li> |
||
| 92 | <li class="level1"><div class="li"> |
||
| 93 | Ordered list item 4 |
||
| 94 | </div></li> |
||
| 95 | </ol> |
||
| 96 | |||
| 97 | <ul> |
||
| 98 | <li class="level1"><div class="li"> |
||
| 99 | Unordered list item |
||
| 100 | </div></li> |
||
| 101 | <li class="level1"><div class="li"> |
||
| 102 | <p> |
||
| 103 | Unordered list item… |
||
| 104 | </p><p> |
||
| 105 | … in multiple paragraphs |
||
| 106 | </p> |
||
| 107 | </div></li> |
||
| 108 | </ul> |
||
| 109 | |||
| 110 | <ol> |
||
| 111 | <li class="level1"><div class="li"> |
||
| 112 | Ordered list, first level |
||
| 113 | </div><ol> |
||
| 114 | <li class="level2"><div class="li"> |
||
| 115 | Second level |
||
| 116 | </div><ol> |
||
| 117 | <li class="level3"><div class="li"> |
||
| 118 | Third level |
||
| 119 | </div><ol> |
||
| 120 | <li class="level4"><div class="li"> |
||
| 121 | Fourth level |
||
| 122 | </div></li> |
||
| 123 | </ol> |
||
| 124 | </li> |
||
| 125 | </ol> |
||
| 126 | </li> |
||
| 127 | <li class="level2"><div class="li"> |
||
| 128 | <p> |
||
| 129 | Back to second level |
||
| 130 | </p> |
||
| 131 | </div><ol> |
||
| 132 | <li class="level3"><div class="li"> |
||
| 133 | <em>Second?! What happened to third?</em> |
||
| 134 | </div></li> |
||
| 135 | </ol> |
||
| 136 | <div class="li"> |
||
| 137 | <p> |
||
| 138 | <em>Quiet, you.</em> |
||
| 139 | </p> |
||
| 140 | </div></li> |
||
| 141 | </ol> |
||
| 142 | </li> |
||
| 143 | <li class="level1"><div class="li"> |
||
| 144 | Back to first level |
||
| 145 | </div></li> |
||
| 146 | <li class="level1"><div class="li"> |
||
| 147 | Still at first level |
||
| 148 | </div></li> |
||
| 149 | </ol> |
||
| 150 | |||
| 151 | <dl> |
||
| 152 | <dt class="level1"><span class="dt"> Definition list</span></dt> |
||
| 153 | <dd class="level1"><div class="dd"> |
||
| 154 | 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>] |
||
| 155 | </div></dd> |
||
| 156 | <dt class="level1"><span class="dt"> Definition list w/ multiple paragraphs</span></dt> |
||
| 157 | <dd class="level1"><div class="dd"> |
||
| 158 | <p> |
||
| 159 | The style sheet provided with this plugin will render these paragraphs… |
||
| 160 | </p><p> |
||
| 161 | … to the left of the term being defined. |
||
| 162 | </p> |
||
| 163 | </div><dl> |
||
| 164 | <dt class="level2"><span class="dt"> Definition list w/ multiple “paragraphs”</span></dt> |
||
| 165 | <dd class="level2"><div class="dd"> |
||
| 166 | Another way to separate blocks of text in a definition… |
||
| 167 | </div></dd> |
||
| 168 | <dd class="level2"><div class="dd"> |
||
| 169 | … is to simply have multiple definitions for a term (or group of terms). |
||
| 170 | </div></dd> |
||
| 171 | </dl> |
||
| 172 | </dd> |
||
| 173 | </dl> |
||
| 174 | |||
| 175 | <dl> |
||
| 176 | <dd class="level1"><div class="dd"> |
||
| 177 | This definition list has DD tags without any preceding DT tags. |
||
| 178 | </div></dd> |
||
| 179 | <dd class="level1"><div class="dd"> |
||
| 180 | Hey, it's legal XHTML. |
||
| 181 | </div></dd> |
||
| 182 | <dt class="level1"><span class="dt"> Just like DT tags without following DD tags.</span></dt> |
||
| 183 | <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> |
||
| 184 | </dl> |
||
| 185 | |||
| 186 | <pre class="code">.. If you try, the result will be rendered oddly.</pre> |
||
| 187 | |||
| 188 | </div>') !== false, |
||
| 189 | 'expected html snippet was not in the output' |
||
| 190 | ); |
||
| 191 | } |
||
| 192 | } |
||
| 193 |
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.