| Conditions | 18 | 
| Paths | 100 | 
| Total Lines | 82 | 
| Code Lines | 49 | 
| 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  | 
            ||
| 19 |     public function cssStyleini($tpl, $preview=false) { | 
            ||
| 20 | global $conf;  | 
            ||
| 21 | |||
| 22 | $stylesheets = array(); // mode, file => base  | 
            ||
| 23 | // guaranteed placeholder => value  | 
            ||
| 24 | $replacements = array(  | 
            ||
| 25 | '__text__' => "#000",  | 
            ||
| 26 | '__background__' => "#fff",  | 
            ||
| 27 | '__text_alt__' => "#999",  | 
            ||
| 28 | '__background_alt__' => "#eee",  | 
            ||
| 29 | '__text_neu__' => "#666",  | 
            ||
| 30 | '__background_neu__' => "#ddd",  | 
            ||
| 31 | '__border__' => "#ccc",  | 
            ||
| 32 | '__highlight__' => "#ff9",  | 
            ||
| 33 | '__link__' => "#00f",  | 
            ||
| 34 | );  | 
            ||
| 35 | |||
| 36 | // load template's style.ini  | 
            ||
| 37 | $incbase = tpl_incdir($tpl);  | 
            ||
| 38 | $webbase = tpl_basedir($tpl);  | 
            ||
| 39 | $ini = $incbase.'style.ini';  | 
            ||
| 40 |         if(file_exists($ini)){ | 
            ||
| 41 | $data = parse_ini_file($ini, true);  | 
            ||
| 42 | |||
| 43 | // stylesheets  | 
            ||
| 44 |             if(is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){ | 
            ||
| 45 |                 if (!file_exists($incbase . $file)) { | 
            ||
| 46 |                     list($extension, $basename) = array_map('strrev', explode('.', strrev($file), 2)); | 
            ||
| 47 | $newExtension = $extension === 'css' ? 'less' : 'css';  | 
            ||
| 48 |                     if (file_exists($incbase . $basename . '.' . $newExtension)) { | 
            ||
| 49 | $stylesheets[$mode][$incbase . $basename . '.' . $newExtension] = $webbase;  | 
            ||
| 50 |                         if ($conf['allowdebug']) { | 
            ||
| 51 |                             msg("Stylesheet $file not found, using $basename.$newExtension instead. Please contact developer of \"{$conf['template']}\" template.", 2); | 
            ||
| 52 | }  | 
            ||
| 53 | continue;  | 
            ||
| 54 | }  | 
            ||
| 55 | }  | 
            ||
| 56 | $stylesheets[$mode][$incbase . $file] = $webbase;  | 
            ||
| 57 | }  | 
            ||
| 58 | |||
| 59 | // replacements  | 
            ||
| 60 |             if(is_array($data['replacements'])){ | 
            ||
| 61 | $replacements = array_merge($replacements, $this->cssFixreplacementurls($data['replacements'],$webbase));  | 
            ||
| 62 | }  | 
            ||
| 63 | }  | 
            ||
| 64 | |||
| 65 | // load configs's style.ini  | 
            ||
| 66 | $webbase = DOKU_BASE;  | 
            ||
| 67 | $ini = DOKU_CONF."tpl/$tpl/style.ini";  | 
            ||
| 68 | $incbase = dirname($ini).'/';  | 
            ||
| 69 |         if(file_exists($ini)){ | 
            ||
| 70 | $data = parse_ini_file($ini, true);  | 
            ||
| 71 | |||
| 72 | // stylesheets  | 
            ||
| 73 |             if(isset($data['stylesheets']) && is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){ | 
            ||
| 74 | $stylesheets[$mode][$incbase.$file] = $webbase;  | 
            ||
| 75 | }  | 
            ||
| 76 | |||
| 77 | // replacements  | 
            ||
| 78 |             if(isset($data['replacements']) && is_array($data['replacements'])){ | 
            ||
| 79 | $replacements = array_merge($replacements, $this->cssFixreplacementurls($data['replacements'],$webbase));  | 
            ||
| 80 | }  | 
            ||
| 81 | }  | 
            ||
| 82 | |||
| 83 | // allow replacement overwrites in preview mode  | 
            ||
| 84 |         if($preview) { | 
            ||
| 85 | $webbase = DOKU_BASE;  | 
            ||
| 86 | $ini = $conf['cachedir'].'/preview.ini';  | 
            ||
| 87 |             if(file_exists($ini)) { | 
            ||
| 88 | $data = parse_ini_file($ini, true);  | 
            ||
| 89 | // replacements  | 
            ||
| 90 |                 if(is_array($data['replacements'])) { | 
            ||
| 91 | $replacements = array_merge($replacements, $this->cssFixreplacementurls($data['replacements'], $webbase));  | 
            ||
| 92 | }  | 
            ||
| 93 | }  | 
            ||
| 94 | }  | 
            ||
| 95 | |||
| 96 | return array(  | 
            ||
| 97 | 'stylesheets' => $stylesheets,  | 
            ||
| 98 | 'replacements' => $replacements  | 
            ||
| 99 | );  | 
            ||
| 100 | }  | 
            ||
| 101 | |||
| 119 |