| Conditions | 1 |
| Paths | 1 |
| Total Lines | 92 |
| Code Lines | 3 |
| 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 |
||
| 159 | public function getSourceContext() |
||
| 160 | { |
||
| 161 | return new Twig_Source("{% extends \"layout/layout.twig\" %} |
||
| 162 | {% from \"macros.twig\" import class_link, namespace_link, method_link, property_link %} |
||
| 163 | {% block title %}Search | {{ parent() }}{% endblock %} |
||
| 164 | {% block body_class 'search-page' %} |
||
| 165 | |||
| 166 | {% block page_content %} |
||
| 167 | |||
| 168 | <div class=\"page-header\"> |
||
| 169 | <h1>Search</h1> |
||
| 170 | </div> |
||
| 171 | |||
| 172 | <p>This page allows you to search through the API documentation for |
||
| 173 | specific terms. Enter your search words into the box below and click |
||
| 174 | \"submit\". The search will be performed on namespaces, classes, interfaces, |
||
| 175 | traits, functions, and methods.</p> |
||
| 176 | |||
| 177 | <form class=\"form-inline\" role=\"form\" action=\"{{ path('search.html') }}\" method=\"GET\"> |
||
| 178 | <div class=\"form-group\"> |
||
| 179 | <label class=\"sr-only\" for=\"search\">Search</label> |
||
| 180 | <input type=\"search\" class=\"form-control\" name=\"search\" id=\"search\" placeholder=\"Search\"> |
||
| 181 | </div> |
||
| 182 | <button type=\"submit\" class=\"btn btn-default\">submit</button> |
||
| 183 | </form> |
||
| 184 | |||
| 185 | <h2>Search Results</h2> |
||
| 186 | |||
| 187 | <div class=\"container-fluid\"> |
||
| 188 | <ul class=\"search-results\"></ul> |
||
| 189 | </div> |
||
| 190 | |||
| 191 | {{ block('js_search') }} |
||
| 192 | |||
| 193 | {% endblock %} |
||
| 194 | |||
| 195 | {% block js_search %} |
||
| 196 | <script type=\"text/javascript\"> |
||
| 197 | |||
| 198 | (function() { |
||
| 199 | var term = Sami.cleanSearchTerm(); |
||
| 200 | |||
| 201 | if (!term) { |
||
| 202 | \$('h2').hide(); |
||
| 203 | return; |
||
| 204 | } |
||
| 205 | |||
| 206 | \$('#search').val(term); |
||
| 207 | var container = \$('.search-results'); |
||
| 208 | var results = Sami.search(term); |
||
| 209 | var len = results.length; |
||
| 210 | |||
| 211 | if (len == 0) { |
||
| 212 | container.html('No results were found'); |
||
| 213 | return; |
||
| 214 | } |
||
| 215 | |||
| 216 | for (var i = 0, text_content = ''; i < len; i++) { |
||
| 217 | |||
| 218 | var ele = results[i]; |
||
| 219 | var contents = '<li><h2 class=\"clearfix\">'; |
||
| 220 | var class_name = Sami.getSearchClass(ele.type); |
||
| 221 | contents += '<a href=\"' + ele.link + '\">' + ele.name + '</a>'; |
||
| 222 | contents += '<div class=\"search-type type-' + ele.type + '\"><span class=\"pull-right label ' + class_name + '\">' + ele.type + '</span></div>'; |
||
| 223 | contents += '</h2>'; |
||
| 224 | |||
| 225 | if (ele.fromName && ele.fromLink) { |
||
| 226 | contents += '<div class=\"search-from\">from <a href=\"' + ele.fromLink + '\">' + ele.fromName + '</a></div>'; |
||
| 227 | } |
||
| 228 | |||
| 229 | contents += '<div class=\"search-description\">'; |
||
| 230 | |||
| 231 | // Add description, decode entities, and strip wrapping quotes |
||
| 232 | if (ele.doc) { |
||
| 233 | text_content = \$('<p>' + ele.doc + '</p>').text(); |
||
| 234 | if (text_content[0] == '\"') { |
||
| 235 | text_content = text_content.substring(1); |
||
| 236 | } |
||
| 237 | if (text_content[text_content.length - 1] == '\"') { |
||
| 238 | text_content = text_content.substring(0, text_content.length - 1); |
||
| 239 | } |
||
| 240 | contents += text_content; |
||
| 241 | } |
||
| 242 | |||
| 243 | contents += '</div></li>'; |
||
| 244 | container.append(\$(contents)); |
||
| 245 | } |
||
| 246 | })(); |
||
| 247 | </script> |
||
| 248 | {% endblock %} |
||
| 249 | ", "search.twig", "phar:///Users/bobby/Dropbox/Sites/OpenSource/Slackify/sami.phar/Sami/Resources/themes/default/search.twig"); |
||
| 250 | } |
||
| 251 | } |
||
| 252 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.