src/Phug/Formatter/Format/TwigXhtmlFormat.php
Method __construct
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __construct(Formatter $formatter = null)
{
$this->setOptionsRecursive([
'white_space_sensitive_tags' => [
'pre',
Function isBlockTag
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function isBlockTag(MarkupInterface $element)
{
if ($element->belongsTo($this->getOption('inline_tags'))) {
return false;
}
- 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
The method isSelfClosingTag has a boolean flag argument $isSelfClosing, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public function isSelfClosingTag(MarkupInterface $element, $isSelfClosing = false)
- Read upRead up
- Exclude checks
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
Parameter $formatter
has undeclared type ?\Phug\Formatter
Open
Open
public function __construct(Formatter $formatter = null)
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::getOption
Open
Open
$this->getOption('self_closing_tags')
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::getOption
Open
Open
if ($element->belongsTo($this->getOption('inline_tags'))) {
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::getOption
Open
Open
return $element->belongsTo($this->getOption('white_space_sensitive_tags'));
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::setOptionsRecursive
Open
Open
$this->setOptionsRecursive([
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::setPattern
Open
Open
$this->setPattern('doctype', $this->pattern(
- Exclude checks
Parameter $element
has undeclared type \Phug\Formatter\MarkupInterface
Open
Open
public function isWhiteSpaceSensitive(MarkupInterface $element)
- Exclude checks
Parameter $element
has undeclared type \Phug\Formatter\MarkupInterface
Open
Open
public function isSelfClosingTag(MarkupInterface $element, $isSelfClosing = false)
- Exclude checks
Call to method hasParent
from undeclared class \Phug\Formatter\MarkupInterface
Open
Open
if ($element->hasParent()) {
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
Open
Open
$this->pattern('doctype_dtd'),
- Exclude checks
Call to method belongsTo
from undeclared class \Phug\Formatter\MarkupInterface
Open
Open
$isSelfClosing || $element->isAutoClosed() || $element->belongsTo(
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
Open
Open
$this->pattern('doctype_dtd_url')
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
Open
Open
$this->pattern('doctype_language'),
- Exclude checks
Call to method belongsTo
from undeclared class \Phug\Formatter\MarkupInterface
Open
Open
return $element->belongsTo($this->getOption('white_space_sensitive_tags'));
- Exclude checks
Parameter $element
has undeclared type \Phug\Formatter\MarkupInterface
Open
Open
protected function isBlockTag(MarkupInterface $element)
- Exclude checks
Call to method getParent
from undeclared class \Phug\Formatter\MarkupInterface
Open
Open
for ($element = $element->getParent(); $element->hasParent(); $element = $element->getParent()) {
- Exclude checks
Call to method belongsTo
from undeclared class \Phug\Formatter\MarkupInterface
Open
Open
if ($element->belongsTo($this->getOption('inline_tags'))) {
- Exclude checks
Call to method isAutoClosed
from undeclared class \Phug\Formatter\MarkupInterface
Open
Open
$isSelfClosing || $element->isAutoClosed() || $element->belongsTo(
- Exclude checks
Checking instanceof against undeclared class \Phug\Formatter\MarkupInterface
Open
Open
if ($element instanceof MarkupInterface) {
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::addPatterns
Open
Open
$this->addPatterns([
- Exclude checks
Call to undeclared method \Phug\Formatter\Format\TwigXhtmlFormat::pattern
Open
Open
$this->setPattern('doctype', $this->pattern(
- Exclude checks