| Conditions | 11 |
| Paths | 16 |
| Total Lines | 44 |
| 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 |
||
| 85 | public static function notification() |
||
| 86 | { |
||
| 87 | $api = self::api_version(); |
||
| 88 | $api_major = $matches = null; |
||
| 89 | if (preg_match('/^(\d+\.\d+)\./', $api, $matches)) |
||
| 90 | { |
||
| 91 | $api_major = $matches[1]; |
||
| 92 | } |
||
| 93 | |||
| 94 | $versions = self::available($api_major); |
||
| 95 | |||
| 96 | if ($versions) |
||
| 97 | { |
||
| 98 | if (version_compare($api, $versions['security'], '<')) |
||
| 99 | { |
||
| 100 | if (!$GLOBALS['egw_info']['user']['apps']['admin'] && !self::update_older($versions['security'], self::WARN_USERS_DAYS)) |
||
| 101 | { |
||
| 102 | return null; |
||
| 103 | } |
||
| 104 | return Html::a_href(Html::image('api', 'security-update', lang('EGroupware security update %1 needs to be installed!', $versions['security'])), |
||
| 105 | 'http://www.egroupware.org/changelog', null, ' target="_blank"'); |
||
| 106 | } |
||
| 107 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && version_compare($api, $versions['current'], '<')) |
||
| 108 | { |
||
| 109 | $msg = substr($versions['current'], 0, strlen($api_major)) == $api_major ? |
||
| 110 | lang('EGroupware maintenance update %1 available', $versions['current']) : |
||
| 111 | lang('New EGroupware release %1 available', $versions['current']); |
||
| 112 | return Html::a_href(Html::image('api', 'update', $msg), |
||
| 113 | 'http://www.egroupware.org/changelog', null, ' target="_blank"'); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | elseif ($GLOBALS['egw_info']['user']['apps']['admin']) |
||
| 117 | { |
||
| 118 | $error = lang('Automatic update check failed, you need to check manually!'); |
||
| 119 | if (!ini_get('allow_url_fopen')) |
||
| 120 | { |
||
| 121 | $error .= "\n".lang('%1 setting "%2" = %3 disallows access via http!', |
||
| 122 | 'php.ini', 'allow_url_fopen', array2string(ini_get('allow_url_fopen'))); |
||
| 123 | } |
||
| 124 | return Html::a_href(Html::image('api', 'update', $error), |
||
| 125 | 'http://www.egroupware.org/changelog', null, ' target="_blank" data-api-version="'.$api.'"'); |
||
| 126 | } |
||
| 127 | return null; |
||
| 128 | } |
||
| 129 | |||
| 175 |