| Conditions | 7 |
| Paths | 8 |
| Total Lines | 67 |
| Code Lines | 47 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 32 |
| CRAP Score | 7.5182 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 35 | 46 | public function __construct($options = array ()) { |
|
| 36 | 46 | $loader = new FilesystemLoader ( \ROOT . \DS . "views" . \DS ); |
|
| 37 | 46 | $loader->addPath ( implode ( \DS, [ Startup::getFrameworkDir (),"..","core","views" ] ) . \DS, "framework" ); |
|
| 38 | 46 | $this->loader = $loader; |
|
| 39 | |||
| 40 | 46 | if (isset ( $options ["cache"] ) && $options ["cache"] === true) { |
|
| 41 | $options ["cache"] = CacheManager::getCacheSubDirectory ( "views" ); |
||
| 42 | } |
||
| 43 | |||
| 44 | 46 | $this->twig = new Environment ( $loader, $options ); |
|
| 45 | |||
| 46 | 46 | if (isset ( $options ["activeTheme"] )) { |
|
| 47 | 45 | ThemesManager::setActiveThemeFromTwig ( $options ["activeTheme"] ); |
|
| 48 | 45 | $this->setTheme ( $options ["activeTheme"], ThemesManager::THEMES_FOLDER ); |
|
| 49 | 45 | unset ( $options ["activeTheme"] ); |
|
| 50 | } else { |
||
| 51 | 3 | $this->loader->setPaths ( [ \ROOT . \DS . 'views' ], "activeTheme" ); |
|
| 52 | } |
||
| 53 | |||
| 54 | $this->addFunction ( 'path', function ($name, $params = [ ], $absolute = false) { |
||
| 55 | return Router::path ( $name, $params, $absolute ); |
||
| 56 | 46 | } ); |
|
| 57 | |||
| 58 | $this->addFunction ( 'url', function ($name, $params) { |
||
| 59 | return Router::url ( $name, $params ); |
||
| 60 | 46 | } ); |
|
| 61 | |||
| 62 | 46 | if (\class_exists ( '\\Ubiquity\\security\\csrf\\UCsrfHttp' )) { |
|
| 63 | $this->addFunction ( 'csrfMeta', function ($name) { |
||
| 64 | return \Ubiquity\security\csrf\UCsrfHttp::getTokenMeta ( $name ); |
||
|
1 ignored issue
–
show
|
|||
| 65 | }, true ); |
||
| 66 | $this->addFunction ( 'csrf', function ($name) { |
||
| 67 | return \Ubiquity\security\csrf\UCsrfHttp::getTokenField ( $name ); |
||
| 68 | }, true ); |
||
| 69 | } |
||
| 70 | |||
| 71 | $this->addFunction ( 'css', function ($resource, $parameters = [ ], $absolute = false) { |
||
| 72 | 7 | if ($this->hasThemeResource ( $resource )) { |
|
| 73 | 7 | return AssetsManager::css_ ( $resource, $parameters, $absolute ); |
|
| 74 | } |
||
| 75 | 1 | return AssetsManager::css ( $resource, $parameters, $absolute ); |
|
| 76 | 46 | }, true ); |
|
| 77 | |||
| 78 | $this->addFunction ( 'js', function ($resource, $parameters = [ ], $absolute = false) { |
||
| 79 | 1 | if ($this->hasThemeResource ( $resource )) { |
|
| 80 | return AssetsManager::js_ ( $resource, $parameters, $absolute ); |
||
| 81 | } |
||
| 82 | 1 | return AssetsManager::js ( $resource, $parameters, $absolute ); |
|
| 83 | 46 | }, true ); |
|
| 84 | |||
| 85 | $t = new TwigFunction ( 't', function ($context, $id, array $parameters = array (), $domain = null, $locale = null) { |
||
| 86 | 1 | $trans = TranslatorManager::trans ( $id, $parameters, $domain, $locale ); |
|
| 87 | 1 | return $this->twig->createTemplate ( $trans )->render ( $context ); |
|
| 88 | 46 | }, [ 'needs_context' => true ] ); |
|
| 89 | |||
| 90 | $tc = new TwigFunction ( 'tc', function ($context, $id, array $choice, array $parameters = array (), $domain = null, $locale = null) { |
||
| 91 | 1 | $trans = TranslatorManager::transChoice ( $id, $choice, $parameters, $domain, $locale ); |
|
| 92 | 1 | return $this->twig->createTemplate ( $trans )->render ( $context ); |
|
| 93 | 46 | }, [ 'needs_context' => true ] ); |
|
| 94 | 46 | $this->twig->addFunction ( $t ); |
|
| 95 | 46 | $this->twig->addFunction ( $tc ); |
|
| 96 | |||
| 97 | $test = new TwigTest ( 'instanceOf', function ($var, $class) { |
||
| 98 | return $var instanceof $class; |
||
| 99 | 46 | } ); |
|
| 100 | 46 | $this->twig->addTest ( $test ); |
|
| 101 | 46 | $this->twig->addGlobal ( "app", new Framework () ); |
|
| 102 | 46 | } |
|
| 187 | } |
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