pug-php/twig

View on GitHub
src/Phug/Formatter/Format/TwigXhtmlFormat.php

Summary

Maintainability
A
3 hrs
Test Coverage
A
100%

Method __construct has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct(Formatter $formatter = null)
    {
        $this->setOptionsRecursive([
            'white_space_sensitive_tags' => [
                'pre',
Severity: Major
Found in src/Phug/Formatter/Format/TwigXhtmlFormat.php - About 2 hrs to fix

    Function isBlockTag has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function isBlockTag(MarkupInterface $element)
        {
            if ($element->belongsTo($this->getOption('inline_tags'))) {
                return false;
            }
    Severity: Minor
    Found in src/Phug/Formatter/Format/TwigXhtmlFormat.php - About 1 hr 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

    The method isSelfClosingTag has a boolean flag argument $isSelfClosing, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function isSelfClosingTag(MarkupInterface $element, $isSelfClosing = false)

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::setOptionsRecursive
    Open

            $this->setOptionsRecursive([

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
    Open

                $this->pattern('doctype_dtd'),

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::getOption
    Open

            if ($element->belongsTo($this->getOption('inline_tags'))) {

    Call to method belongsTo from undeclared class \Phug\Formatter\MarkupInterface
    Open

            return $element->belongsTo($this->getOption('white_space_sensitive_tags'));

    Parameter $element has undeclared type \Phug\Formatter\MarkupInterface
    Open

        protected function isBlockTag(MarkupInterface $element)

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::setPattern
    Open

            $this->setPattern('doctype', $this->pattern(

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
    Open

                $this->pattern('doctype_dtd_url')

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::getOption
    Open

                    $this->getOption('self_closing_tags')

    Call to method belongsTo from undeclared class \Phug\Formatter\MarkupInterface
    Open

                $isSelfClosing || $element->isAutoClosed() || $element->belongsTo(

    Call to method hasParent from undeclared class \Phug\Formatter\MarkupInterface
    Open

            if ($element->hasParent()) {

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
    Open

                $this->pattern('doctype_language'),

    Call to method belongsTo from undeclared class \Phug\Formatter\MarkupInterface
    Open

            if ($element->belongsTo($this->getOption('inline_tags'))) {

    Parameter $formatter has undeclared type ?\Phug\Formatter
    Open

        public function __construct(Formatter $formatter = null)

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::getOption
    Open

            return $element->belongsTo($this->getOption('white_space_sensitive_tags'));

    Parameter $element has undeclared type \Phug\Formatter\MarkupInterface
    Open

        public function isWhiteSpaceSensitive(MarkupInterface $element)

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::addPatterns
    Open

            $this->addPatterns([

    Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
    Open

            $this->setPattern('doctype', $this->pattern(

    Call to method getParent from undeclared class \Phug\Formatter\MarkupInterface
    Open

                for ($element = $element->getParent(); $element->hasParent(); $element = $element->getParent()) {

    Parameter $element has undeclared type \Phug\Formatter\MarkupInterface
    Open

        public function isSelfClosingTag(MarkupInterface $element, $isSelfClosing = false)

    Call to method isAutoClosed from undeclared class \Phug\Formatter\MarkupInterface
    Open

                $isSelfClosing || $element->isAutoClosed() || $element->belongsTo(

    Checking instanceof against undeclared class \Phug\Formatter\MarkupInterface
    Open

                    if ($element instanceof MarkupInterface) {

    There are no issues that match your filters.

    Category
    Status