| Conditions | 11 |
| Paths | 5 |
| Total Lines | 91 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 41 | public function init($flextype, $app) : void |
||
| 42 | { |
||
| 43 | // Set empty themes list item |
||
| 44 | $this->flextype['registry']->set('themes', []); |
||
| 45 | |||
| 46 | // Get themes list |
||
| 47 | $themes_list = $this->getThemes(); |
||
| 48 | |||
| 49 | // If Themes List isnt empty then continue |
||
| 50 | if (! is_array($themes_list) || count($themes_list) <= 0) { |
||
| 51 | return; |
||
| 52 | } |
||
| 53 | |||
| 54 | // Get themes cache ID |
||
| 55 | $themes_cache_id = $this->getThemesCacheID($themes_list); |
||
| 56 | |||
| 57 | // Get themes list from cache or scan themes folder and create new themes cache item in the registry |
||
| 58 | if ($this->flextype['cache']->contains($themes_cache_id)) { |
||
| 59 | $this->flextype['registry']->set('themes', $this->flextype['cache']->fetch($themes_cache_id)); |
||
| 60 | } else { |
||
| 61 | $themes = []; |
||
| 62 | $themes_settings = []; |
||
| 63 | $themes_manifest = []; |
||
| 64 | $default_theme_settings = []; |
||
| 65 | $site_theme_settings = []; |
||
| 66 | $default_theme_manifest = []; |
||
| 67 | |||
| 68 | // Go through the themes list... |
||
| 69 | foreach ($themes_list as $theme) { |
||
| 70 | |||
| 71 | // Set custom theme directory |
||
| 72 | $custom_theme_settings_dir = PATH['project'] . '/config/themes/' . $theme['dirname']; |
||
| 73 | |||
| 74 | // Set default theme settings and manifest files |
||
| 75 | $default_theme_settings_file = PATH['project'] . '/themes/' . $theme['dirname'] . '/settings.yaml'; |
||
| 76 | $default_theme_manifest_file = PATH['project'] . '/themes/' . $theme['dirname'] . '/theme.yaml'; |
||
| 77 | |||
| 78 | // Set custom theme settings and manifest files |
||
| 79 | $custom_theme_settings_file = PATH['project'] . '/config/themes/' . $theme['dirname'] . '/settings.yaml'; |
||
| 80 | |||
| 81 | // Create custom theme settings directory |
||
| 82 | ! Filesystem::has($custom_theme_settings_dir) and Filesystem::createDir($custom_theme_settings_dir); |
||
| 83 | |||
| 84 | // Check if default theme settings file exists |
||
| 85 | if (! Filesystem::has($default_theme_settings_file)) { |
||
| 86 | throw new RuntimeException('Load ' . $theme['dirname'] . ' theme settings - failed!'); |
||
| 87 | } |
||
| 88 | |||
| 89 | // Get default theme manifest content |
||
| 90 | $default_theme_settings_file_content = Filesystem::read($default_theme_settings_file); |
||
| 91 | if (trim($default_theme_settings_file_content) === '') { |
||
| 92 | $default_theme_settings = []; |
||
| 93 | } else { |
||
| 94 | $default_theme_settings = $this->flextype['serializer']->decode($default_theme_settings_file_content, 'yaml'); |
||
| 95 | } |
||
| 96 | |||
| 97 | // Create custom theme settings file |
||
| 98 | ! Filesystem::has($custom_theme_settings_file) and Filesystem::write($custom_theme_settings_file, $default_theme_settings_file_content); |
||
| 99 | |||
| 100 | // Get custom theme settings content |
||
| 101 | $custom_theme_settings_file_content = Filesystem::read($custom_theme_settings_file); |
||
| 102 | if (trim($custom_theme_settings_file_content) === '') { |
||
| 103 | $custom_theme_settings = []; |
||
| 104 | } else { |
||
| 105 | $custom_theme_settings = $this->flextype['serializer']->decode($custom_theme_settings_file_content, 'yaml'); |
||
| 106 | } |
||
| 107 | |||
| 108 | // Check if default theme manifest file exists |
||
| 109 | if (! Filesystem::has($default_theme_manifest_file)) { |
||
| 110 | RuntimeException('Load ' . $theme['dirname'] . ' theme manifest - failed!'); |
||
| 111 | } |
||
| 112 | |||
| 113 | // Get default theme manifest content |
||
| 114 | $default_theme_manifest_file_content = Filesystem::read($default_theme_manifest_file); |
||
| 115 | $default_theme_manifest = $this->flextype['serializer']->decode($default_theme_manifest_file_content, 'yaml'); |
||
| 116 | |||
| 117 | // Merge theme settings and manifest data |
||
| 118 | $themes[$theme['dirname']]['manifest'] = $default_theme_manifest; |
||
| 119 | $themes[$theme['dirname']]['settings'] = array_replace_recursive($default_theme_settings, $custom_theme_settings); |
||
| 120 | |||
| 121 | } |
||
| 122 | |||
| 123 | // Save parsed themes list in the registry themes |
||
| 124 | $this->flextype['registry']->set('themes', $themes); |
||
| 125 | |||
| 126 | // Save parsed themes list in the cache |
||
| 127 | $this->flextype['cache']->save($themes_cache_id, $themes); |
||
| 128 | } |
||
| 129 | |||
| 130 | // Emit onThemesInitialized |
||
| 131 | $this->flextype['emitter']->emit('onThemesInitialized'); |
||
| 132 | } |
||
| 259 |
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