| Conditions | 10 | 
| Paths | 41 | 
| Total Lines | 36 | 
| Code Lines | 26 | 
| 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 | ||
| 13 | public static function include_code() | ||
| 14 |     { | ||
| 15 |         if (Director::is_ajax()) { | ||
| 16 | self::block(); | ||
| 17 |         } else { | ||
| 18 | Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js"); | ||
| 19 |             Requirements::javascript('prettyphoto/javascript/jquery.prettyPhoto.js'); | ||
| 20 |             Requirements::css('prettyphoto/css/prettyPhoto.css'); | ||
| 21 | |||
| 22 | $config = ''; | ||
| 23 |             $theme = Config::inst()->get("PrettyPhoto", "theme"); | ||
| 24 |             $moreConfigArray = Config::inst()->get("PrettyPhoto", "more_config"); | ||
| 25 |             foreach ($moreConfigArray as $key => $value) { | ||
| 26 |                 if ($value === false) { | ||
| 27 | $value = "false"; | ||
| 28 |                 } elseif ($value === true) { | ||
| 29 | $value = "true"; | ||
| 30 |                 } elseif ($value === intval($value)) { | ||
| 31 | //$value = $value; | ||
| 32 |                 } else { | ||
| 33 | $value = " '$value' "; | ||
| 34 | } | ||
| 35 | $moreConfigArray[$key] = "$key: $value"; | ||
| 36 | } | ||
| 37 |             if ($theme) { | ||
| 38 | $config .= "theme: '".$theme."'"; | ||
| 39 | } | ||
| 40 |             if ($config && count($moreConfigArray)) { | ||
| 41 | $config .= ", "; | ||
| 42 | } | ||
| 43 |             if (count($moreConfigArray)) { | ||
| 44 |                 $config .= implode(",", $moreConfigArray); | ||
| 45 | } | ||
| 46 |             Requirements::customScript('PrettyPhotoInitConfigs = {'.$config.'}; jQuery(document).ready(function(){PrettyPhotoLoader.load("'.Config::inst()->get("PrettyPhoto", "selector").'")});', "prettyPhotoCustomScript"); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 57 | 
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.