Showing 20 of 20 total issues
File Tag.php
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace HnhDigital\LaravelHtmlBuilder;
use HnhDigital\LaravelHtmlGenerator\Html;
Tag
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Tag
{
private static $tag_registry = [];
private static $special_tags = [
'img', 'br', 'hr', 'input', 'area', 'link', 'meta', 'param',
Function buildHtml
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private static function buildHtml(&$html, $tag_object, $options, $tab = 0)
{
self::checkBuildOptions($options);
$tag_is_special = in_array($tag_object->getTag(), self::$special_tags);
- 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 buildArray
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private static function buildArray(&$array, $tag_object, $options = [])
{
self::checkBuildOptions($options);
if (in_array($tag_object->getTag(), self::$special_tags)) {
- 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 add
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function add($tag, ...$arguments)
{
$tag = strtolower($tag);
$text = '';
$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"
Further reading
Method buildHtml
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function buildHtml(&$html, $tag_object, $options, $tab = 0)
{
self::checkBuildOptions($options);
$tag_is_special = in_array($tag_object->getTag(), self::$special_tags);
Method add
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add($tag, ...$arguments)
{
$tag = strtolower($tag);
$text = '';
$attributes = [];
Method buildFromArray
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function buildFromArray(&$html, $array, $tab = 0)
{
$pad = '';
if ($tab > 0) {
$pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT);
Function buildHtmlAttribute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function buildHtmlAttribute($attributes)
{
$html = '';
foreach ($attributes as $name => $value) {
if (is_array($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 buildFromArray
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function buildFromArray(&$html, $array, $tab = 0)
{
$pad = '';
if ($tab > 0) {
$pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT);
- 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
Avoid classes with short names like Tr. Configured minimum length is 3. Open
class Tr extends Tag
{
protected $tag = 'tr';
protected $allowed_tags = ['td', 'th'];
}
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Li. Configured minimum length is 3. Open
class Li extends Tag
{
protected $tag = 'li';
protected $use_whitespace = false;
}
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Ul. Configured minimum length is 3. Open
class Ul extends Tag
{
protected $tag = 'ul';
protected $allowed_tags = ['li'];
}
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Ol. Configured minimum length is 3. Open
class Ol extends Tag
{
protected $tag = 'ol';
protected $allowed_tags = ['li'];
}
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Th. Configured minimum length is 3. Open
class Th extends Tag
{
protected $tag = 'th';
protected $allowed_tags = [];
protected $allowed_text = true;
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Avoid classes with short names like Td. Configured minimum length is 3. Open
class Td extends Tag
{
protected $tag = 'td';
protected $allowed_tags = [];
protected $allowed_text = true;
- Read upRead up
- Exclude checks
ShortClassName
Since: 2.9
Detects when classes or interfaces have a very short name.
Example
class Fo {
}
interface Fo {
}
Source https://phpmd.org/rules/naming.html#shortclassname
Missing class import via use statement (line '140', column '23'). Open
throw new \Exception(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '544', column '19'). Open
throw new \Exception($this->tag.' does permit '.$tag);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '103', column '23'). Open
throw new \Exception($tag.' does not exist.');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '106', column '19'). Open
throw new \Exception($this->tag.' does permit '.$tag);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}