Showing 16 of 137 total issues
Function create
has a Cognitive Complexity of 272 (exceeds 5 allowed). Consider refactoring. Open
public static function create($string, $allowSlashes = false)
{
$slug = '';
$string = html_entity_decode($string, ENT_QUOTES);
- 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 xmlEscape
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public static function xmlEscape($str)
{
// array used to figure what number to decrement from character order value
// according to number of characters used to map unicode to ascii by utf-8
$decrement = [];
- 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 URLUtils.php
has 310 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Gdbots\Common\Util;
final class URLUtils
Method create
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create($string, $allowSlashes = false)
{
$slug = '';
$string = html_entity_decode($string, ENT_QUOTES);
Method xmlEscape
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function xmlEscape($str)
{
// array used to figure what number to decrement from character order value
// according to number of characters used to map unicode to ascii by utf-8
$decrement = [];
Consider simplifying this complex logical expression. Open
} else if (($c >= 8219 && $c <= 8223) || $c == 8242 || $c == 8243 || $c == 8216 || $c == 8217 || $c == 168 || $c == 180 || $c == 729 || $c == 733) {
//all the strange curly single and double quotes
// Ignore them
} else if ($c == 188) {
$slug .= '-one-quarter-';
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create($str, $camelize = true)
{
// remove special chars (accents, etc.)
$str = trim(self::normalize($str));
$str = ltrim($str, '#_ ');
Function varToString
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function varToString($var)
{
if (is_object($var)) {
return sprintf('Object(%s)', get_class($var));
}
- 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 create
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function create($str, $camelize = true)
{
// remove special chars (accents, etc.)
$str = trim(self::normalize($str));
$str = ltrim($str, '#_ ');
- 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
Consider simplifying this complex logical expression. Open
if (($c >= 224 && $c <= 229) || ($c >= 192 && $c <= 198) || ($c >= 281 && $c <= 286)) {
$slug .= 'a';
} else if (($c >= 232 && $c <= 235) || ($c >= 200 && $c <= 203)) {
$slug .= 'e';
} else if (($c >= 236 && $c <= 239) || ($c >= 204 && $c <= 207)) {
Function isValid
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function isValid($hashtag)
{
$hashtag = ltrim($hashtag, '#');
if (empty($hashtag)) {
return 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 'false';
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return 'true';
Avoid too many return
statements within this method. Open
return (string)$var;