edde-framework/edde-framework

View on GitHub
src/Edde/Common/Strings/StringUtils.php

Summary

Maintainability
B
6 hrs
Test Coverage

StringUtils has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

    class StringUtils extends Object {
        private static $SEPARATOR_LIST = [
            '|',
            ':',
            '.',
Severity: Minor
Found in src/Edde/Common/Strings/StringUtils.php - About 3 hrs to fix

Function match has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        static public function match(string $string, string $pattern, bool $named = false, bool $trim = false) {
            $match = null;
            $match = self::pcre('preg_match', [
                $pattern,
                $string,
Severity: Minor
Found in src/Edde/Common/Strings/StringUtils.php - About 1 hr 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 toAscii has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        static public function toAscii(string $string): string {
            $string = preg_replace('~[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]~u', '', $string);
            $string = strtr($string, '`\'"^~?', "\x01\x02\x03\x04\x05\x06");
            $string = str_replace([
                "\xE2\x80\x9E",
Severity: Minor
Found in src/Edde/Common/Strings/StringUtils.php - About 1 hr to fix

Function matchAll has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        static public function matchAll(string $string, string $pattern, bool $named = false, $trim = false): array {
            $match = null;
            $match = self::pcre('preg_match_all', [
                $pattern,
                $string,
Severity: Minor
Found in src/Edde/Common/Strings/StringUtils.php - About 1 hr 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

There are no issues that match your filters.

Category
Status