Conditions | 27 |
Paths | 208 |
Total Lines | 90 |
Code Lines | 61 |
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 function __construct($themePath, $themeUrl) |
||
86 | { |
||
87 | $this->_themeUrl = $themeUrl; |
||
88 | $this->_themePath = realpath($themePath); |
||
89 | $this->_name = basename($themePath); |
||
90 | $cacheValid = false; |
||
91 | // TODO: the following needs to be cleaned up (Qiang) |
||
92 | if(($cache = $this->getApplication()->getCache()) !== null) |
||
93 | { |
||
94 | $array = $cache->get(self::THEME_CACHE_PREFIX . $themePath); |
||
95 | if(is_array($array)) |
||
96 | { |
||
97 | list($skins, $cssFiles, $jsFiles, $timestamp) = $array; |
||
98 | if($this->getApplication()->getMode() !== TApplicationMode::Performance) |
||
99 | { |
||
100 | if(($dir = opendir($themePath)) === false) |
||
101 | throw new TIOException('theme_path_inexistent', $themePath); |
||
102 | $cacheValid = true; |
||
103 | while(($file = readdir($dir)) !== false) |
||
104 | { |
||
105 | if($file === '.' || $file === '..') |
||
106 | continue; |
||
107 | elseif(basename($file, '.css') !== $file) |
||
108 | $this->_cssFiles[] = $themeUrl . '/' . $file; |
||
109 | elseif(basename($file, '.js') !== $file) |
||
110 | $this->_jsFiles[] = $themeUrl . '/' . $file; |
||
111 | elseif(basename($file, self::SKIN_FILE_EXT) !== $file && filemtime($themePath . DIRECTORY_SEPARATOR . $file) > $timestamp) |
||
112 | { |
||
113 | $cacheValid = false; |
||
114 | break; |
||
115 | } |
||
116 | } |
||
117 | closedir($dir); |
||
118 | if($cacheValid) |
||
119 | $this->_skins = $skins; |
||
120 | } |
||
121 | else |
||
122 | { |
||
123 | $cacheValid = true; |
||
124 | $this->_cssFiles = $cssFiles; |
||
125 | $this->_jsFiles = $jsFiles; |
||
126 | $this->_skins = $skins; |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | if(!$cacheValid) |
||
131 | { |
||
132 | $this->_cssFiles = []; |
||
133 | $this->_jsFiles = []; |
||
134 | $this->_skins = []; |
||
135 | if(($dir = opendir($themePath)) === false) |
||
136 | throw new TIOException('theme_path_inexistent', $themePath); |
||
137 | while(($file = readdir($dir)) !== false) |
||
138 | { |
||
139 | if($file === '.' || $file === '..') |
||
140 | continue; |
||
141 | elseif(basename($file, '.css') !== $file) |
||
142 | $this->_cssFiles[] = $themeUrl . '/' . $file; |
||
143 | elseif(basename($file, '.js') !== $file) |
||
144 | $this->_jsFiles[] = $themeUrl . '/' . $file; |
||
145 | elseif(basename($file, self::SKIN_FILE_EXT) !== $file) |
||
146 | { |
||
147 | $template = new TTemplate(file_get_contents($themePath . '/' . $file), $themePath, $themePath . '/' . $file); |
||
148 | foreach($template->getItems() as $skin) |
||
149 | { |
||
150 | if(!isset($skin[2])) // a text string, ignored |
||
151 | continue; |
||
152 | elseif($skin[0] !== -1) |
||
153 | throw new TConfigurationException('theme_control_nested', $skin[1], dirname($themePath)); |
||
154 | $type = $skin[1]; |
||
155 | $id = isset($skin[2]['skinid'])?$skin[2]['skinid']:0; |
||
156 | unset($skin[2]['skinid']); |
||
157 | if(isset($this->_skins[$type][$id])) |
||
158 | throw new TConfigurationException('theme_skinid_duplicated', $type, $id, dirname($themePath)); |
||
159 | /* |
||
160 | foreach($skin[2] as $name=>$value) |
||
161 | { |
||
162 | if(is_array($value) && ($value[0]===TTemplate::CONFIG_DATABIND || $value[0]===TTemplate::CONFIG_PARAMETER)) |
||
163 | throw new TConfigurationException('theme_databind_forbidden',dirname($themePath),$type,$id); |
||
164 | } |
||
165 | */ |
||
166 | $this->_skins[$type][$id] = $skin[2]; |
||
167 | } |
||
168 | } |
||
169 | } |
||
170 | closedir($dir); |
||
171 | sort($this->_cssFiles); |
||
172 | sort($this->_jsFiles); |
||
173 | if($cache !== null) |
||
174 | $cache->set(self::THEME_CACHE_PREFIX . $themePath, [$this->_skins,$this->_cssFiles,$this->_jsFiles,time()]); |
||
175 | } |
||
346 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths