includes/ResourceLoader/VueComponentParser.php
Method newTemplateFormatter
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function newTemplateFormatter( $minify ) {
return new class( $minify ) extends HtmlFormatter {
private $minify;
public function __construct( $minify ) {
Method newFilteringDispatcher
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function newFilteringDispatcher( TreeBuilder $treeBuilder, $nodeName ) {
return new class( $treeBuilder, $nodeName ) extends Dispatcher {
private $nodeName;
private $nodeDepth = 0;
private $seenTag = false;
Method startTag
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function startTag( $name, Attributes $attrs, $selfClose, $sourceStart, $sourceLength ) {
Method characters
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function characters( $text, $start, $length, $sourceStart, $sourceLength ) {
Function validateAttributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
private function validateAttributes( DOMNode $node, array $allowedAttributes ): void {
if ( $allowedAttributes ) {
foreach ( $node->attributes as $attr ) {
if ( !in_array( $attr->name, $allowedAttributes ) ) {
throw new InvalidArgumentException( "<{$node->nodeName}> may not have the " .
- 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 findUniqueTags
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private function findUniqueTags( DOMNode $rootNode, array $tagNames ): array {
$nodes = [];
foreach ( $rootNode->childNodes as $node ) {
$tagName = strtolower( $node->nodeName );
if ( in_array( $tagName, $tagNames ) ) {
- 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"