| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 128 | public function renderPost(Renderer $renderer) |
||
| 129 | { |
||
| 130 | $coreformsjs = $renderer->basepath('/Core/js/core.forms.js'); |
||
|
|
|||
| 131 | $javaScript = <<<JS |
||
| 132 | $(document).ready(function() { |
||
| 133 | |||
| 134 | console.log('attached yk.forms.done to ', \$('form')); |
||
| 135 | |||
| 136 | \$('form').on('yk.forms.done', function(event, data) { |
||
| 137 | //if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {} |
||
| 138 | if (typeof data != 'undefined' && typeof data['data'] != 'undefined') { |
||
| 139 | if (typeof data['data']['jobvalid'] != 'undefined' && data['data']['jobvalid'] === true) { |
||
| 140 | $('#job_incomplete').hide(); |
||
| 141 | \$('.wizard-container .finish').removeClass('disabled'); |
||
| 142 | } |
||
| 143 | else { |
||
| 144 | $('#job_incomplete').show(); |
||
| 145 | \$('.wizard-container .finish').addClass('disabled'); |
||
| 146 | } |
||
| 147 | } |
||
| 148 | \$('#job_errormessages').empty(); |
||
| 149 | |||
| 150 | if (typeof data['data']['errorMessage'] != 'undefined') { |
||
| 151 | $('#job_errormessages').append(data['data']['errorMessage']); |
||
| 152 | } |
||
| 153 | console.debug('job-form-inline', event, data); |
||
| 154 | }); |
||
| 155 | \$('.wizard-container').on('wizard:tabShow.jobcontainer', function(e, \$tab, \$nav, index) { |
||
| 156 | var \$link = \$tab.find('a'); |
||
| 157 | var href = \$link.attr('href'); |
||
| 158 | var \$target = \$(href); |
||
| 159 | var \$iframe = \$target.find('iframe'); |
||
| 160 | |||
| 161 | \$iframe.each(function() { this.contentDocument.location.reload(true); }); |
||
| 162 | |||
| 163 | var \$productList = \$target.find('#product-list-wrapper'); |
||
| 164 | if (\$productList.length) { |
||
| 165 | \$productList.html('').load('/' + lang + '/jobs/channel-list?id=' + \$('#general-nameForm-job').val()); |
||
| 166 | } |
||
| 167 | }); |
||
| 168 | |||
| 169 | \$('.wizard-container .finish a').click(function (e) { |
||
| 170 | if (\$(e.currentTarget).parent().hasClass('disabled')) { |
||
| 171 | e.preventDefault(); |
||
| 172 | return false; |
||
| 173 | } |
||
| 174 | }); |
||
| 175 | |||
| 176 | }); |
||
| 177 | JS; |
||
| 178 | |||
| 179 | $renderer->headScript()->appendScript($javaScript); |
||
| 180 | |||
| 181 | return parent::renderPost($renderer); |
||
| 182 | } |
||
| 183 | |||
| 196 |
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.