phug-php/formatter

View on GitHub
Formatter/Format/XmlFormat.php

Summary

Maintainability
D
2 days
Test Coverage

Showing 12 of 12 total issues

File XmlFormat.php has 448 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
 
namespace Phug\Formatter\Format;
 
use Closure;
Severity: Minor
Found in Formatter/Format/XmlFormat.php - About 6 hrs to fix

    Method yieldAssignmentElement has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    protected function yieldAssignmentElement(AssignmentElement $element)
    {
    foreach ($this->getOption('assignment_handlers') as $handler) {
    $iterator = $handler($element) ?: [];
     
     
    Severity: Major
    Found in Formatter/Format/XmlFormat.php - About 2 hrs to fix

      XmlFormat has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class XmlFormat extends AbstractFormat
      {
      use AssignmentHelpersTrait;
       
      const DOCTYPE = '<?xml version="1.0" encoding="utf-8" ?>';
      Severity: Minor
      Found in Formatter/Format/XmlFormat.php - About 2 hrs to fix

        Function formatAttributeElement has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        protected function formatAttributeElement(AttributeElement $element)
        {
        $value = $element->getValue();
        $name = $element->getName();
        $nonEmptyAttribute = ($name === 'class' || $name === 'id');
        Severity: Minor
        Found in Formatter/Format/XmlFormat.php - About 2 hrs to fix

        Method formatAttributeElement has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        protected function formatAttributeElement(AttributeElement $element)
        {
        $value = $element->getValue();
        $name = $element->getName();
        $nonEmptyAttribute = ($name === 'class' || $name === 'id');
        Severity: Minor
        Found in Formatter/Format/XmlFormat.php - About 1 hr to fix

          Function hasNonStaticAttributes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          protected function hasNonStaticAttributes(MarkupInterface $element)
          {
          if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
          foreach ($element->getAttributes() as $attribute) {
          if ($attribute->hasStaticMember('value')) {
          Severity: Minor
          Found in Formatter/Format/XmlFormat.php - About 1 hr to fix

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

          protected function yieldAssignmentElement(AssignmentElement $element)
          {
          foreach ($this->getOption('assignment_handlers') as $handler) {
          $iterator = $handler($element) ?: [];
           
           
          Severity: Minor
          Found in Formatter/Format/XmlFormat.php - About 1 hr to fix

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

          public function __construct(?Formatter $formatter = null)
          {
          parent::__construct($formatter);
           
          $this
          Severity: Minor
          Found in Formatter/Format/XmlFormat.php - About 1 hr to fix

            Function hasDuplicateAttributeNames has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            protected function hasDuplicateAttributeNames(MarkupInterface $element)
            {
            if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
            $names = [];
            foreach ($element->getAttributes() as $attribute) {
            Severity: Minor
            Found in Formatter/Format/XmlFormat.php - About 55 mins to fix

            Function formatAttributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            protected function formatAttributes(MarkupElement $element)
            {
            if ($this->hasNonStaticAttributes($element) ||
            $this->hasDuplicateAttributeNames($element)) {
            $empty = true;
            Severity: Minor
            Found in Formatter/Format/XmlFormat.php - About 55 mins to fix

            Consider simplifying this complex logical expression.
            Open

            if ($nonEmptyAttribute && (
            !$value ||
            ($value instanceof TextElement && ((string) $value->getValue()) === '') ||
            (is_string($value) && in_array(trim($value), ['', '""', "''"], true))
            )) {
            Severity: Major
            Found in Formatter/Format/XmlFormat.php - About 40 mins to fix

              Avoid too many return statements within this method.
              Open

              return $this->pattern(
              'attribute_pattern',
              $this->format($name),
              $this->format($value)
              );
              Severity: Major
              Found in Formatter/Format/XmlFormat.php - About 30 mins to fix
                Category
                Status