Showing 20 of 20 total issues
Function generateNodes
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
public static function generateNodes(string $html): array
{
$matchedNodes = $elementNodes = $resolvedNodes = [];
$html = \preg_replace(['/\n\s*/', '/\s+<\//', '/\"\s+\>/', '/\"\s+\s+/'], [' ', '</', '">', '" '], $html) ?? $html;
- 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
File elements.php
has 412 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
/*
Function renderAttributes
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public static function renderAttributes(array $attributes): string
{
$attribute = '';
foreach ($attributes as $name => $value) {
- 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 find
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function find(string $template, RenderInterface &$render = null): ?string
{
if ($cachedTemplate = &$this->loadedTemplates[$template] ?? null) {
[$loadedTemplate, $renderOffset] = $cachedTemplate;
- 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 cssFromArray
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function cssFromArray(array $style): ?string
{
$result = '';
foreach ($style as $name => $value) {
- 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 generateNodes
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function generateNodes(string $html): array
{
$matchedNodes = $elementNodes = $resolvedNodes = [];
$html = \preg_replace(['/\n\s*/', '/\s+<\//', '/\"\s+\>/', '/\"\s+\s+/'], [' ', '</', '">', '" '], $html) ?? $html;
Function findTemplate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function findTemplate(string $name, bool $throw = true): ?string
{
if (isset($this->cache[$name])) {
return $this->cache[$name];
}
- 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 generateHtml
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function generateHtml(array $elementNodes, callable $resolveNode = null, array $options = []): string
{
$content = '';
if (null !== ($indentLevel = $options['indentLevel'] ?? null) && $indentLevel < 2) {
- 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 parentHas
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function parentHas(array $attrNames, AbstractNode $tagNode = null): bool
{
if (null !== $tagParent = $this->parent) {
foreach ($tagParent->children as $childNode) {
if (!$childNode instanceof SelfCloseNode) {
- 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 load
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function load(string $template, array $namespaces): ?string
{
$fileFailures = [];
if (\file_exists($template)) {
- 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 render
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render(string $template, array $parameters): string
{
$source = self::loadHtml($template) ?? $template;
if ($source !== $template || !\file_exists($template)) {
Method find
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function find(string $template, RenderInterface &$render = null): ?string
{
if ($cachedTemplate = &$this->loadedTemplates[$template] ?? null) {
[$loadedTemplate, $renderOffset] = $cachedTemplate;
Method renderAttributes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function renderAttributes(array $attributes): string
{
$attribute = '';
foreach ($attributes as $name => $value) {
Method initializeEscapers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function initializeEscapers(): void
{
$flags = \ENT_NOQUOTES | \ENT_SUBSTITUTE;
$this->escapers = [
Function doParseNode
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private static function doParseNode(Node\AbstractNode $tagNode, int $offset, array &$elementNodes, array &$resolvedNodes): void
{
$lastKey = \array_key_last($elementNodes);
$previousNode = null !== $lastKey ? $elementNodes[$lastKey] : null;
- 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 has
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function has(array $attrNames, AttributeNode &$attrNode = null): bool
{
$attrName = null;
foreach ($this->attributes as $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
Method forTagWithParent
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function forTagWithParent(string $tagName, ?string $attrName = null, ?string $parent = null, bool $first = false, bool $void = false, bool $voidAttr = false): self
Avoid too many return
statements within this method. Open
return \addcslashes($value, "\x00..\x1F!\"#$%&'()*+,./:;<=>?@[\\]^`{|}~");
Function addLocation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addLocation(string $location, string $loaderClassName = null): void
{
if (null !== $loaderClassName) {
foreach ($this->loaders as $loader) {
if ($loaderClassName === \get_class($loader)) {
- 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 createElement
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function createElement(string $tag, $attributes = [], bool $selfClosing = null): string
{
$html = '<' . $tag;
if (\is_array($attributes)) {
- 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"