| Conditions | 1 |
| Paths | 1 |
| Total Lines | 70 |
| Code Lines | 67 |
| 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 namespace XoopsModules\Tdmcreate\Files\Assets\Js; |
||
| 95 | public function getJavascriptJQueryPrint() |
||
| 96 | { |
||
| 97 | $ret = <<<'EOT' |
||
| 98 | // <![CDATA[ |
||
| 99 | /*------------------------------------------------------------------------------ |
||
| 100 | Excerpts from the jsUtilities Library |
||
| 101 | Version: 2.1 |
||
| 102 | Homepage: http://www.easy-designs.net/code/jsUtilities/ |
||
| 103 | License: Creative Commons Attribution-ShareAlike 2.0 License |
||
| 104 | http://creativecommons.org/licenses/by-sa/2.0/ |
||
| 105 | Note: If you change or improve on this script, please let us know. |
||
| 106 | ------------------------------------------------------------------------------*/ |
||
| 107 | if(Array.prototype.push === null) { |
||
| 108 | Array.prototype.push = function(item) { |
||
| 109 | this[this.length] = item; |
||
| 110 | return this.length; |
||
| 111 | } |
||
| 112 | } |
||
| 113 | // --------------------------------------------------------------------- |
||
| 114 | // function.apply (if unsupported) |
||
| 115 | // Courtesy of Aaron Boodman - http://youngpup.net |
||
| 116 | // --------------------------------------------------------------------- |
||
| 117 | if (!Function.prototype.apply) { |
||
| 118 | Function.prototype.apply = function(oScope, args) { |
||
| 119 | var sarg = []; |
||
| 120 | var rtrn, call; |
||
| 121 | if (!oScope) oScope = window; |
||
| 122 | if (!args) args = []; |
||
| 123 | for (var i = 0; i < args.length; i++) { |
||
| 124 | sarg[i] = "args["+i+"]"; |
||
| 125 | } |
||
| 126 | call = "oScope.__applyTemp__(" + sarg.join(",") + ");"; |
||
| 127 | oScope.__applyTemp__ = this; |
||
| 128 | rtrn = eval(call); |
||
| 129 | oScope.__applyTemp__ = null; |
||
| 130 | return rtrn; |
||
| 131 | } |
||
| 132 | } |
||
| 133 | function inArray(needle) { |
||
| 134 | for (var i=0; i < this.length; i++) { |
||
| 135 | if (this[i] === needle) { |
||
| 136 | return i; |
||
| 137 | } |
||
| 138 | } |
||
| 139 | return false; |
||
| 140 | } |
||
| 141 | function addClass(theClass) { |
||
| 142 | if (this.className != '') { |
||
| 143 | this.className += ' ' + theClass; |
||
| 144 | } else { |
||
| 145 | this.className = theClass; |
||
| 146 | } |
||
| 147 | } |
||
| 148 | function lastChildContainingText() { |
||
| 149 | var testChild = this.lastChild; |
||
| 150 | var contentCntnr = ['p','li','dd']; |
||
| 151 | while (testChild.nodeType != 1) { |
||
| 152 | testChild = testChild.previousSibling; |
||
| 153 | } |
||
| 154 | var tag = testChild.tagName.toLowerCase(); |
||
| 155 | var tagInArr = inArray.apply(contentCntnr, [tag]); |
||
| 156 | if (!tagInArr && tagInArr!==0) { |
||
| 157 | testChild = lastChildContainingText.apply(testChild); |
||
| 158 | } |
||
| 159 | return testChild; |
||
| 160 | } |
||
| 161 | // ]]> |
||
| 162 | EOT; |
||
| 163 | |||
| 164 | return $ret; |
||
| 165 | } |
||
| 187 |