src/Pug/Engine/Options.php

Summary

Maintainability
A
25 mins
Test Coverage
A
100%

Function extractExtensionsFromKeywords has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function extractExtensionsFromKeywords(&$options)
    {
        if (isset($options['keywords'])) {
            foreach ($options['keywords'] as $keyword) {
                if ($keyword instanceof ExtensionContainerInterface) {
Severity: Minor
Found in src/Pug/Engine/Options.php - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid using static access to class '\Phug\Phug' in method 'extractExtensionsFromKeywords'.
Open

                    $options = array_merge($options, Phug::getExtensionsOptions([$keyword->getExtension()]));
Severity: Minor
Found in src/Pug/Engine/Options.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Call to method __construct from undeclared class \JsPhpize\JsPhpizePhug
Open

            $compiler->addModule(new JsPhpizePhug($compiler));
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

Argument 1 (extension) is \Phug\JsTransformerExtension but \Pug\Engine\Options::addExtension() takes \Phug\ExtensionInterface defined at /code/src/Pug/Engine/Keywords.php:42
Open

        $this->addExtension(new JsTransformerExtension());
Severity: Minor
Found in src/Pug/Engine/Options.php by phan

Call to undeclared method \Pug\Engine\Options::getCompiler
Open

        $compiler = $this->getCompiler();
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

Reference to constant class from undeclared class \Phug\Formatter\Format\HtmlFormat
Open

                $options['formats'][$format] = HtmlFormat::class;
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

Call to method getExtensionsOptions from undeclared class \Phug\Phug
Open

                    $options = array_merge($options, Phug::getExtensionsOptions([$keyword->getExtension()]));
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

Reference to constant class from undeclared class \Phug\Renderer\Adapter\FileAdapter
Open

            $options['adapterclassname'] = FileAdapter::class;
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

Call to undeclared method \Pug\Engine\Options::getCompiler
Open

            $compiler = $this->getCompiler();
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

Call to undeclared method \Pug\Engine\Options::getOption
Open

                $compiler->setOption($option, $this->getOption($option));
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

Call to method __construct from undeclared class \Phug\JsTransformerExtension
Open

        $this->addExtension(new JsTransformerExtension());
Severity: Critical
Found in src/Pug/Engine/Options.php by phan

There are no issues that match your filters.

Category
Status