| Conditions | 13 |
| Paths | 12 |
| Total Lines | 52 |
| Code Lines | 28 |
| 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 |
||
| 78 | protected function applySEO() |
||
| 79 | { |
||
| 80 | $config = $this->getConfig(); |
||
| 81 | $logged_info = Context::get('logged_info'); |
||
| 82 | |||
| 83 | foreach ($this->SEO as $type => $list) { |
||
| 84 | if (!$list || !count($list)) continue; |
||
| 85 | |||
| 86 | foreach ($list as $val) { |
||
| 87 | if ($type == 'meta') { |
||
| 88 | $attr_name = $val['attr_name']; |
||
| 89 | Context::addHtmlHeader('<meta ' . $attr_name . '="' . $val['property'] . '" content="' . $val['content'] . '" />'); |
||
| 90 | } elseif ($type == 'link') { |
||
| 91 | Context::addHtmlHeader('<link rel="' . $val['rel'] . '" href="' . $val['href'] . '" />'); |
||
| 92 | } |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | // Google Analytics |
||
| 97 | if ($config->ga_id && !($config->ga_except_admin == 'Y' && $logged_info->is_admin == 'Y')) { |
||
| 98 | $gaq_push = array(); |
||
| 99 | // $gaq_push[] = '_gaq.push([\'_setAccount\', \'' . $config->ga_id . '\']);'; |
||
| 100 | $gaq_push[] = "ga('create', '{$config->ga_id}', 'auto');"; |
||
| 101 | $canonical_url = str_replace(Context::get('request_uri'), '/', $this->canonical_url); |
||
| 102 | $gaq_push[] = "ga('send', 'pageview', '{$canonical_url}');"; |
||
| 103 | $gaq_push = implode(PHP_EOL, $gaq_push); |
||
| 104 | |||
| 105 | $ga_script = <<< GASCRIPT |
||
| 106 | <!-- Google Analytics --> |
||
| 107 | <script> |
||
| 108 | (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
||
| 109 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
||
| 110 | m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
||
| 111 | })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
||
| 112 | |||
| 113 | {$gaq_push} |
||
| 114 | </script> |
||
| 115 | GASCRIPT; |
||
| 116 | |||
| 117 | Context::addHtmlHeader($ga_script . PHP_EOL); |
||
| 118 | } |
||
| 119 | |||
| 120 | // Naver Analytics |
||
| 121 | if ($config->na_id && !($config->na_except_admin == 'Y' && $logged_info->is_admin == 'Y')) { |
||
| 122 | $na_script = <<< NASCRIPT |
||
| 123 | <!-- NAVER Analytics --> |
||
| 124 | <script src="//wcs.naver.net/wcslog.js"></script> |
||
| 125 | <script>if(!wcs_add){var wcs_add={wa:'{$config->na_id}'};}if(typeof wcs_do!="undefined"){wcs_do();}</script> |
||
| 126 | NASCRIPT; |
||
| 127 | Context::addHtmlFooter($na_script . PHP_EOL); |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 186 |
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.