gdbots/pbj-php

View on GitHub
src/Util/SlugUtil.php

Summary

Maintainability
F
6 days
Test Coverage

Function create has a Cognitive Complexity of 272 (exceeds 5 allowed). Consider refactoring.
Open

    public static function create(string $string, bool $allowSlashes = false): string
    {
        $slug = '';
        $string = html_entity_decode($string, ENT_QUOTES);

Severity: Minor
Found in src/Util/SlugUtil.php - About 5 days to fix

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 create has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function create(string $string, bool $allowSlashes = false): string
    {
        $slug = '';
        $string = html_entity_decode($string, ENT_QUOTES);

Severity: Major
Found in src/Util/SlugUtil.php - About 3 hrs to fix

    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-';
    Severity: Critical
    Found in src/Util/SlugUtil.php - About 2 hrs to fix

      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)) {
      Severity: Major
      Found in src/Util/SlugUtil.php - About 40 mins to fix

        There are no issues that match your filters.

        Category
        Status