Showing 44 of 44 total issues

File Util.php has 511 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare(strict_types=1);

namespace stk2k\util;

Severity: Major
Found in src/Util.php - About 1 day to fix

    Function getByteSizeFromString has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getByteSizeFromString( string $size_string ) : float
        {
            if ( ($pos=strpos($size_string,'TB')) > 0 ){
                // TB
                $number = substr($size_string,0,$pos);
    Severity: Minor
    Found in src/MemoryUtil.php - About 7 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

    Function toString has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function toString($value, bool $with_type = false, int $max_size = self::TOSTRING_MAX_LENGTH, string $tostring_methods = '__toString,toString' ): string
        {
            $ret = '';
    
            if ( $value === NULL ){
    Severity: Minor
    Found in src/Util.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

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

    final class Util
    {
        /* length of output in string conversion methods */
        const TOSTRING_MAX_LENGTH     = 9999;
        
    Severity: Minor
    Found in src/Util.php - About 3 hrs to fix

      Method _dump has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function _dump( $key, $value, $depth, $max_string_length, &$lines, $max_depth, &$recursion )
          {
              if ( $depth > $max_depth ){
                  $lines[] = str_repeat( '.', $depth * 4 ) . "----(max depth over:$max_depth)";
                  return;
      Severity: Major
      Found in src/Util.php - About 2 hrs to fix

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

            private static function _dump( $key, $value, $depth, $max_string_length, &$lines, $max_depth, &$recursion )
            {
                if ( $depth > $max_depth ){
                    $lines[] = str_repeat( '.', $depth * 4 ) . "----(max depth over:$max_depth)";
                    return;
        Severity: Minor
        Found in src/Util.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 toString has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function toString($value, bool $with_type = false, int $max_size = self::TOSTRING_MAX_LENGTH, string $tostring_methods = '__toString,toString' ): string
            {
                $ret = '';
        
                if ( $value === NULL ){
        Severity: Minor
        Found in src/Util.php - About 2 hrs to fix

          Function process has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public function process(string $str, callable $handler = null) : string
              {
                  $keyword_list = self::findMacroKeywords($str);
          
                  if (empty($keyword_list)){
          Severity: Minor
          Found in src/MacroProcessor.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 dump has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function dump($var, string $format = 'html', int $back = 0, array $options = null, bool $return = false, int $max_depth = 6 ): ?string
              {
                  list( $file, $line ) = self::caller( $back );
          
                  if ( !$options ){
          Severity: Minor
          Found in src/Util.php - About 1 hr to fix

            Function __construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __construct(array $default_handlers = [])
                {
                    foreach($default_handlers as $handler)
                    {
                        if (is_string($handler)){
            Severity: Minor
            Found in src/MacroProcessor.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 convertEncodingRecursive has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function convertEncodingRecursive($var, string $to_encoding = null, string $from_encoding = null)
                {
                    $type = gettype($var);
                    switch( $type ){
                    case 'string':
            Severity: Minor
            Found in src/Util.php - About 1 hr to fix

              Method process has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function process(string $keyword) : string
                  {
                      switch($keyword){
                          case 'SERVER_NAME':
                          case 'REQUEST_METHOD':
              Severity: Minor
              Found in src/handler/ServerMacroHandler.php - About 1 hr to fix

                Method process has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function process(string $keyword) : string
                    {
                        switch($keyword){
                            case 'DATE_NOW':
                                return strval(time());
                Severity: Minor
                Found in src/handler/DateMacroHandler.php - About 1 hr to fix

                  Method getByteSizeFromString has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function getByteSizeFromString( string $size_string ) : float
                      {
                          if ( ($pos=strpos($size_string,'TB')) > 0 ){
                              // TB
                              $number = substr($size_string,0,$pos);
                  Severity: Minor
                  Found in src/MemoryUtil.php - About 1 hr to fix

                    Method addNamedHandler has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function addNamedHandler(string $key) : MacroProcessor
                        {
                            switch($key){
                            case EnumMacroHandler::HANDLER_KEY_SYSTEM:
                                self::addHandler(new SystemMacroHandler());
                    Severity: Minor
                    Found in src/MacroProcessor.php - About 1 hr to fix

                      Method process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function process(string $str, callable $handler = null) : string
                          {
                              $keyword_list = self::findMacroKeywords($str);
                      
                              if (empty($keyword_list)){
                      Severity: Minor
                      Found in src/MacroProcessor.php - About 1 hr to fix

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

                            public function addNamedHandler(string $key) : MacroProcessor
                            {
                                switch($key){
                                case EnumMacroHandler::HANDLER_KEY_SYSTEM:
                                    self::addHandler(new SystemMacroHandler());
                        Severity: Minor
                        Found in src/MacroProcessor.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

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

                            public static function dump($var, string $format = 'html', int $back = 0, array $options = null, bool $return = false, int $max_depth = 6 ): ?string
                            {
                                list( $file, $line ) = self::caller( $back );
                        
                                if ( !$options ){
                        Severity: Minor
                        Found in src/Util.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 convertEncodingRecursive has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function convertEncodingRecursive($var, string $to_encoding = null, string $from_encoding = null)
                            {
                                $type = gettype($var);
                                switch( $type ){
                                case 'string':
                        Severity: Minor
                        Found in src/Util.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

                        Method _dump has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            private static function _dump( $key, $value, $depth, $max_string_length, &$lines, $max_depth, &$recursion )
                        Severity: Major
                        Found in src/Util.php - About 50 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language