src/Pug/Engine/Options.php
Function extractExtensionsFromKeywords
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function extractExtensionsFromKeywords(&$options)
{
if (isset($options['keywords'])) {
foreach ($options['keywords'] as $keyword) {
if ($keyword instanceof ExtensionContainerInterface) {
- Read upRead up
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
Open
$options = array_merge($options, Phug::getExtensionsOptions([$keyword->getExtension()]));
- Read upRead up
- Exclude checks
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 getExtensionsOptions
from undeclared class \Phug\Phug
Open
Open
$options = array_merge($options, Phug::getExtensionsOptions([$keyword->getExtension()]));
- Exclude checks
Argument 1 (extension)
is \Phug\JsTransformerExtension
but \Pug\Engine\Options::addExtension()
takes \Phug\ExtensionInterface
defined at /code/src/Pug/Engine/Keywords.php:42
Open
Open
$this->addExtension(new JsTransformerExtension());
- Exclude checks
Reference to constant class
from undeclared class \Phug\Renderer\Adapter\FileAdapter
Open
Open
$options['adapterclassname'] = FileAdapter::class;
- Exclude checks
Call to undeclared method \Pug\Engine\Options::getCompiler
Open
Open
$compiler = $this->getCompiler();
- Exclude checks
Call to method __construct
from undeclared class \Phug\JsTransformerExtension
Open
Open
$this->addExtension(new JsTransformerExtension());
- Exclude checks
Reference to constant class
from undeclared class \Phug\Formatter\Format\HtmlFormat
Open
Open
$options['formats'][$format] = HtmlFormat::class;
- Exclude checks
Call to undeclared method \Pug\Engine\Options::getOption
Open
Open
$compiler->setOption($option, $this->getOption($option));
- Exclude checks
Call to undeclared method \Pug\Engine\Options::getCompiler
Open
Open
$compiler = $this->getCompiler();
- Exclude checks
Call to method __construct
from undeclared class \JsPhpize\JsPhpizePhug
Open
Open
$compiler->addModule(new JsPhpizePhug($compiler));
- Exclude checks