luyadev/yii-helpers

View on GitHub

Showing 51 of 53 total issues

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

    private static function determineNumberFormatType($num_format)
    {
        $num_format = preg_replace("/\[(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow)\]/i", "", $num_format);
        if ($num_format == 'GENERAL') {
            return 'n_auto';
Severity: Minor
Found in src/helpers/XLSXWriter.php - About 1 hr to fix

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

        private static function determineNumberFormatType($num_format)
        {
            $num_format = preg_replace("/\[(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow)\]/i", "", $num_format);
            if ($num_format == 'GENERAL') {
                return 'n_auto';
    Severity: Minor
    Found in src/helpers/XLSXWriter.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 writeSheetHeader has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function writeSheetHeader($sheet_name, array $header_types, $col_options = null)
        {
            if (empty($sheet_name) || empty($header_types) || !empty($this->sheets[$sheet_name])) {
                return;
            }
    Severity: Minor
    Found in src/helpers/XLSXWriter.php - About 1 hr to fix

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

          protected function finalizeSheet($sheet_name)
          {
              if (empty($sheet_name) || $this->sheets[$sheet_name]->finalized) {
                  return;
              }
      Severity: Minor
      Found in src/helpers/XLSXWriter.php - About 1 hr to fix

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

            public static function csvFromResource($resource, array $options = []): array
            {
                if (!is_resource($resource)) {
                    throw new \InvalidArgumentException("The provided resource is not a valid resource.");
                }
        Severity: Minor
        Found in src/helpers/ImportHelper.php - About 1 hr to fix

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

              protected function buildWorkbookXML()
              {
                  $i = 0;
                  $workbook_xml = "";
                  $workbook_xml .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n";
          Severity: Minor
          Found in src/helpers/XLSXWriter.php - About 1 hr to fix

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

                protected function initializeSheet(
                    $sheet_name,
                    $col_widths = [],
                    $auto_filter = false,
                    $freeze_rows = false,
            Severity: Minor
            Found in src/helpers/XLSXWriter.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 coverSensitiveValues has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function coverSensitiveValues(array $data, array $keys = [])
                {
                    if (empty($keys)) {
                        $keys = self::$sensitiveDefaultKeys;
                    }
            Severity: Minor
            Found in src/helpers/ArrayHelper.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

            Consider simplifying this complex logical expression.
            Open

                        if ($ignore_until == '' && ($c == ' ' || $c == '-' || $c == '(' || $c == ')') && ($i == 0 || $num_format[$i - 1] != '_')) {
                            $escaped .= "\\" . $c;
                        } else {
                            $escaped .= $c;
                        }
            Severity: Major
            Found in src/helpers/XLSXWriter.php - About 1 hr to fix

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

                  public static function filterMatch($value, $conditions, $caseSensitive = true)
                  {
                      if (is_scalar($conditions)) {
                          $conditions = self::explode($conditions, ",", true, true);
                      }
              Severity: Minor
              Found in src/helpers/StringHelper.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 folderToZip has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  private static function folderToZip($folder, &$zipFile, $exclusiveLength)
                  {
                      $handle = opendir($folder);
                      while (false !== $f = readdir($handle)) {
                          if ($f != '.' && $f != '..') {
              Severity: Minor
              Found in src/helpers/ZipHelper.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 writeToFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function writeToFile($filename)
                  {
                      foreach ($this->sheets as $sheet_name => $sheet) {
                          $this->finalizeSheet($sheet_name);//making sure all footers have been written
                      }
              Severity: Minor
              Found in src/helpers/XLSXWriter.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

              Method writeCell has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      XLSXWriter_BuffererWriter &$file,
                      $row_number,
                      $column_number,
                      $value,
                      $num_format_type,
              Severity: Minor
              Found in src/helpers/XLSXWriter.php - About 45 mins to fix

                Method markMergedCell has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function markMergedCell($sheet_name, $start_cell_row, $start_cell_column, $end_cell_row, $end_cell_column)
                Severity: Minor
                Found in src/helpers/XLSXWriter.php - About 35 mins to fix

                  Method truncateMiddle has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static function truncateMiddle($content, $word, $length, $affix = '..', $caseSensitive = false)
                  Severity: Minor
                  Found in src/helpers/StringHelper.php - About 35 mins to fix

                    Method initializeSheet has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            $sheet_name,
                            $col_widths = [],
                            $auto_filter = false,
                            $freeze_rows = false,
                            $freeze_columns = false
                    Severity: Minor
                    Found in src/helpers/XLSXWriter.php - About 35 mins to fix

                      Method template has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public static function template($template, array $variables = [], $removeEmpty = false, $leftDelimiter = '{{', $rightDelimiter = '}}')
                      Severity: Minor
                      Found in src/helpers/StringHelper.php - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return 'n_datetime';
                        Severity: Major
                        Found in src/helpers/XLSXWriter.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return 'n_numeric';
                          Severity: Major
                          Found in src/helpers/XLSXWriter.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return 'n_date';
                            Severity: Major
                            Found in src/helpers/XLSXWriter.php - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language