Showing 22 of 22 total issues
Function shortcode
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private function shortcode(array &$names)
{
if(!$this->match(self::TOKEN_OPEN, false)) { return false; }
$offset = $this->tokens[$this->position - 1][2];
$this->match(self::TOKEN_WS, 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 shortcode
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function shortcode(array &$names)
{
if(!$this->match(self::TOKEN_OPEN, false)) { return false; }
$offset = $this->tokens[$this->position - 1][2];
$this->match(self::TOKEN_WS, false);
File RegularParser.php
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Thunder\Shortcode\Parser;
use Thunder\Shortcode\Shortcode\ParsedShortcode;
use Thunder\Shortcode\Shortcode\Shortcode;
Function parseParameters
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private static function parseParameters($text)
{
$text = preg_replace('/[\x{00a0}\x{200b}]+/u', ' ', $text);
if(!preg_match_all(static::$argumentsRegex, $text, $matches, PREG_SET_ORDER)) {
- 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 parse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function parse($text)
{
$nestingLevel = ini_set('xdebug.max_nesting_level', '-1');
$this->tokens = $this->tokenize($text);
$this->backtracks = array();
- 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 parameters
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function parameters()
{
$parameters = array();
while(true) {
- 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 tokenize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function tokenize($text)
{
$count = preg_match_all($this->lexerRegex, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
if(false === $count || preg_last_error() !== PREG_NO_ERROR) {
throw new \RuntimeException(sprintf('PCRE failure `%s`.', preg_last_error()));
- 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 processIteration
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processIteration($text, ProcessorContext $context, ProcessedShortcode $parent = null)
{
if (null !== $this->recursionDepth && $context->recursionLevel > $this->recursionDepth) {
return $text;
}
Method parse
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse($text)
{
$nestingLevel = ini_set('xdebug.max_nesting_level', '-1');
$this->tokens = $this->tokenize($text);
$this->backtracks = array();
Method getObject
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
private function getObject($name, $parameters, $bbCode, $offset, $content, $text)
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$openingTag = null,
$closingTag = null,
$closingTagMarker = null,
$parameterValueSeparator = null,
$parameterValueDelimiter = null
Function value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function value()
{
$value = '';
if($this->match(self::TOKEN_DELIMITER, 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
Avoid too many return
statements within this method. Open
return array($this->getObject($name, $parameters, $bbCode, $offset, null, $this->getBacktrack()));
Avoid too many return
statements within this method. Open
if(false === $bbCode) { return false; }
Avoid too many return
statements within this method. Open
return $closingName;
Avoid too many return
statements within this method. Open
if(false === ($parameters = $this->parameters())) { return false; }
Avoid too many return
statements within this method. Open
if(!$this->match(self::TOKEN_CLOSE, false)) { return false; }
Avoid too many return
statements within this method. Open
return array($this->getObject($name, $parameters, $bbCode, $offset, $content, $this->getBacktrack()));
Avoid too many return
statements within this method. Open
return \in_array($closingName, $names, true) ? $closingName : false;
Avoid too many return
statements within this method. Open
if(!$this->close($names)) { return false; }