| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 7 |
| 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 |
||
| 136 | public function renderPost(Renderer $renderer) |
||
| 137 | { |
||
| 138 | $coreformsjs = $renderer->basepath('/Core/js/core.forms.js'); |
||
|
|
|||
| 139 | $javaScript = <<<JS |
||
| 140 | $(document).ready(function() { |
||
| 141 | |||
| 142 | console.log('attached yk.forms.done to ', \$('form')); |
||
| 143 | |||
| 144 | \$('form').on('yk.forms.done', function(event, data) { |
||
| 145 | //if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {} |
||
| 146 | if (typeof data != 'undefined' && typeof data['data'] != 'undefined') { |
||
| 147 | if (typeof data['data']['jobvalid'] != 'undefined' && data['data']['jobvalid'] === true) { |
||
| 148 | $('#job_incomplete').hide(); |
||
| 149 | \$('.wizard-container .finish').removeClass('disabled'); |
||
| 150 | } |
||
| 151 | else { |
||
| 152 | $('#job_incomplete').show(); |
||
| 153 | \$('.wizard-container .finish').addClass('disabled'); |
||
| 154 | } |
||
| 155 | } |
||
| 156 | \$('#job_errormessages').empty(); |
||
| 157 | |||
| 158 | if (typeof data['data']['errorMessage'] != 'undefined') { |
||
| 159 | $('#job_errormessages').append(data['data']['errorMessage']); |
||
| 160 | } |
||
| 161 | console.debug('job-form-inline', event, data); |
||
| 162 | }); |
||
| 163 | \$('.wizard-container').on('wizard:tabShow.jobcontainer', function(e, \$tab, \$nav, index) { |
||
| 164 | var \$link = \$tab.find('a'); |
||
| 165 | var href = \$link.attr('href'); |
||
| 166 | var \$target = \$(href); |
||
| 167 | var \$iframe = \$target.find('iframe'); |
||
| 168 | |||
| 169 | \$iframe.each(function() { this.contentDocument.location.reload(true); }); |
||
| 170 | |||
| 171 | var \$productList = \$target.find('#product-list-wrapper'); |
||
| 172 | if (\$productList.length) { |
||
| 173 | \$productList.html('').load('/' + lang + '/jobs/channel-list?id=' + \$('#general-nameForm-job').val()); |
||
| 174 | } |
||
| 175 | }); |
||
| 176 | |||
| 177 | \$('.wizard-container .finish a').click(function (e) { |
||
| 178 | if (\$(e.currentTarget).parent().hasClass('disabled')) { |
||
| 179 | e.preventDefault(); |
||
| 180 | return false; |
||
| 181 | } |
||
| 182 | }); |
||
| 183 | |||
| 184 | }); |
||
| 185 | JS; |
||
| 186 | |||
| 187 | $renderer->headScript()->appendScript($javaScript); |
||
| 188 | |||
| 189 | return parent::renderPost($renderer); |
||
| 190 | } |
||
| 191 | |||
| 204 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.