File AbstractFormat.php
has 806 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Phug\Formatter;
use Phug\Formatter;
AbstractFormat
has 40 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class AbstractFormat implements FormatInterface, OptionInterface
{
use HandleVariable;
use OptionTrait;
use PatternTrait;
Method formatMixinCallElement
has 117 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatMixinCallElement(MixinCallElement $mixinCall)
{
$hasBlock = $mixinCall->hasChildren();
$children = new PhpUnwrap($this->formatElementChildren($mixinCall), $this->formatter);
$mixinName = $mixinCall->getName();
Method formatMixinElement
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatMixinElement(MixinElement $mixin)
{
$mixinName = $mixin->getName();
$name = is_string($mixinName)
? var_export($mixinName, true)
Method __construct
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(Formatter $formatter = null)
{
$patterns = [
'class_attribute' => static::CLASS_ATTRIBUTE,
'string_attribute' => static::STRING_ATTRIBUTE,
Function handleTokens
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function handleTokens($code, $checked)
{
$phpTokenHandler = $this->getOption('php_token_handlers');
$untouched = 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
Method handleTokens
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handleTokens($code, $checked)
{
$phpTokenHandler = $this->getOption('php_token_handlers');
$untouched = false;
Function formatMixinCallElement
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function formatMixinCallElement(MixinCallElement $mixinCall)
{
$hasBlock = $mixinCall->hasChildren();
$children = new PhpUnwrap($this->formatElementChildren($mixinCall), $this->formatter);
$mixinName = $mixinCall->getName();
- 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
Function formatElementChildren
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function formatElementChildren(ElementInterface $element, $indentStep = 1)
{
$indentLevel = $this->formatter->getLevel();
$this->formatter->setLevel($indentLevel + $indentStep);
$content = '';
- 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
Method formatElementChildren
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatElementChildren(ElementInterface $element, $indentStep = 1)
{
$indentLevel = $this->formatter->getLevel();
$this->formatter->setLevel($indentLevel + $indentStep);
$content = '';
Method setFormatter
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setFormatter(Formatter $formatter)
{
$this->formatter = $formatter;
$format = $this;
Method formatKeywordElement
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatKeywordElement(KeywordElement $element)
{
$name = $element->getName();
$keyword = $this->getOption(['keywords', $name]);
$result = call_user_func($keyword, $element->getValue(), $element, $name);
Function formatExpressionElement
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function formatExpressionElement(ExpressionElement $code)
{
$value = $this->formatCode($code->getValue(), $code->isChecked(), !$code->isTransformationAllowed());
if ($code->hasStaticValue()) {
- 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
Function __construct
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(Formatter $formatter = null)
{
$patterns = [
'class_attribute' => static::CLASS_ATTRIBUTE,
'string_attribute' => static::STRING_ATTRIBUTE,
- 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
Function formatDynamicValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function formatDynamicValue($formattedName, $value)
{
if ($value instanceof ExpressionElement &&
strtolower($value->getValue()) === 'undefined'
) {
- 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"