File XmlFormat.php
has 448 lines of code (exceeds 250 allowed). Consider refactoring.
<?php
namespace Phug\Formatter\Format;
use Closure;
Method yieldAssignmentElement
has 70 lines of code (exceeds 25 allowed). Consider refactoring.
protected function yieldAssignmentElement(AssignmentElement $element)
{
foreach ($this->getOption('assignment_handlers') as $handler) {
$iterator = $handler($element) ?: [];
XmlFormat
has 24 functions (exceeds 20 allowed). Consider refactoring.
class XmlFormat extends AbstractFormat
{
use AssignmentHelpersTrait;
const DOCTYPE = '<?xml version="1.0" encoding="utf-8" ?>';
Function formatAttributeElement
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
protected function formatAttributeElement(AttributeElement $element)
{
$value = $element->getValue();
$name = $element->getName();
$nonEmptyAttribute = ($name === 'class' || $name === 'id');
Method formatAttributeElement
has 48 lines of code (exceeds 25 allowed). Consider refactoring.
protected function formatAttributeElement(AttributeElement $element)
{
$value = $element->getValue();
$name = $element->getName();
$nonEmptyAttribute = ($name === 'class' || $name === 'id');
Function hasNonStaticAttributes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
protected function hasNonStaticAttributes(MarkupInterface $element)
{
if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
foreach ($element->getAttributes() as $attribute) {
if ($attribute->hasStaticMember('value')) {
Function yieldAssignmentElement
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
protected function yieldAssignmentElement(AssignmentElement $element)
{
foreach ($this->getOption('assignment_handlers') as $handler) {
$iterator = $handler($element) ?: [];
Method __construct
has 31 lines of code (exceeds 25 allowed). Consider refactoring.
public function __construct(?Formatter $formatter = null)
{
parent::__construct($formatter);
$this
Function hasDuplicateAttributeNames
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
protected function hasDuplicateAttributeNames(MarkupInterface $element)
{
if ($element instanceof MarkupElement || $element instanceof MixinCallElement) {
$names = [];
foreach ($element->getAttributes() as $attribute) {
Function formatAttributes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
protected function formatAttributes(MarkupElement $element)
{
if ($this->hasNonStaticAttributes($element) ||
$this->hasDuplicateAttributeNames($element)) {
$empty = true;
Consider simplifying this complex logical expression.
if ($nonEmptyAttribute && (
!$value ||
($value instanceof TextElement && ((string) $value->getValue()) === '') ||
(is_string($value) && in_array(trim($value), ['', '""', "''"], true))
)) {
Avoid too many return
statements within this method.
return $this->pattern(
'attribute_pattern',
$this->format($name),
$this->format($value)
);
There are no issues that match your filters.