strata-mvc/strata

View on GitHub
src/Utility/StringUtility.php

Summary

Maintainability
F
6 days
Test Coverage

Function truncate has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
Open

    public static function truncate($text, $length = 100, $options = array())
    {
        $defaults = array(
            'ellipsis' => '...', 'exact' => true, 'html' => false
        );
Severity: Minor
Found in src/Utility/StringUtility.php - About 1 day 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

File StringUtility.php has 485 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * String handling methods.
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
Severity: Minor
Found in src/Utility/StringUtility.php - About 7 hrs to fix

    Function tokenize has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')')
        {
            if (empty($data)) {
                return array();
            }
    Severity: Minor
    Found in src/Utility/StringUtility.php - About 6 hrs 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 truncate has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function truncate($text, $length = 100, $options = array())
        {
            $defaults = array(
                'ellipsis' => '...', 'exact' => true, 'html' => false
            );
    Severity: Major
    Found in src/Utility/StringUtility.php - About 3 hrs to fix

      Function uuid has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function uuid()
          {
              $node = getenv('SERVER_ADDR');
              if (strpos($node, ':') !== false) {
                  if (substr_count($node, '::')) {
      Severity: Minor
      Found in src/Utility/StringUtility.php - About 3 hrs 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 uuid has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function uuid()
          {
              $node = getenv('SERVER_ADDR');
              if (strpos($node, ':') !== false) {
                  if (substr_count($node, '::')) {
      Severity: Major
      Found in src/Utility/StringUtility.php - About 2 hrs to fix

        Method tokenize has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')')
            {
                if (empty($data)) {
                    return array();
                }
        Severity: Major
        Found in src/Utility/StringUtility.php - About 2 hrs to fix

          Method cleanInsert has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function cleanInsert($str, $options)
              {
                  $clean = $options['clean'];
                  if (!$clean) {
                      return $str;
          Severity: Major
          Found in src/Utility/StringUtility.php - About 2 hrs to fix

            Function wordWrap has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function wordWrap($text, $width = 72, $break = "\n", $cut = false)
                {
                    if ($cut) {
                        $parts = array();
                        while (mb_strlen($text) > 0) {
            Severity: Minor
            Found in src/Utility/StringUtility.php - About 2 hrs 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 insert has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function insert($str, $data, $options = array())
                {
                    $defaults = array(
                        'before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false
                    );
            Severity: Minor
            Found in src/Utility/StringUtility.php - About 1 hr to fix

              Method wordWrap has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function wordWrap($text, $width = 72, $break = "\n", $cut = false)
                  {
                      if ($cut) {
                          $parts = array();
                          while (mb_strlen($text) > 0) {
              Severity: Minor
              Found in src/Utility/StringUtility.php - About 1 hr to fix

                Method highlight has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function highlight($text, $phrase, $options = array())
                    {
                        if (empty($phrase)) {
                            return $text;
                        }
                Severity: Minor
                Found in src/Utility/StringUtility.php - About 1 hr to fix

                  Function insert has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function insert($str, $data, $options = array())
                      {
                          $defaults = array(
                              'before' => ':', 'after' => null, 'escape' => '\\', 'format' => null, 'clean' => false
                          );
                  Severity: Minor
                  Found in src/Utility/StringUtility.php - About 55 mins 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

                  Function highlight has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function highlight($text, $phrase, $options = array())
                      {
                          if (empty($phrase)) {
                              return $text;
                          }
                  Severity: Minor
                  Found in src/Utility/StringUtility.php - About 45 mins 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

                  Function cleanInsert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function cleanInsert($str, $options)
                      {
                          $clean = $options['clean'];
                          if (!$clean) {
                              return $str;
                  Severity: Minor
                  Found in src/Utility/StringUtility.php - About 35 mins 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

                  Function wrap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function wrap($text, $options = array())
                      {
                          if (is_numeric($options)) {
                              $options = array('width' => $options);
                          }
                  Severity: Minor
                  Found in src/Utility/StringUtility.php - About 25 mins 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