techno-express/mailreader

View on GitHub
decode/MailParser.php

Summary

Maintainability
D
2 days
Test Coverage

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

    public function getBody(string $returnType = null)
    {
        $body = '';
        $detectedContentType = false;
        $contentTransferEncoding = null;
Severity: Minor
Found in decode/MailParser.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

File MailParser.php has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

namespace Mail;

use \Mail_mimeDecode;
Severity: Minor
Found in decode/MailParser.php - About 6 hrs to fix

    Function decode has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        public function decode($attachment_directory = null, $saving = true)
        {
            if ($this->raw !== null) {
                if (!empty($attachment_directory))
                    $this->attachment_directory = $attachment_directory;
    Severity: Minor
    Found in decode/MailParser.php - About 5 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 decodePart has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        private function decodePart($body_part, $saving = true)
        {
            if (isset($body_part->ctype_parameters) && \is_array($body_part->ctype_parameters)) {
                if (\array_key_exists('name', $body_part->ctype_parameters)) {
                    $filename = $body_part->ctype_parameters['name'];
    Severity: Minor
    Found in decode/MailParser.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

    MailParser has 30 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    class MailParser
    {
        protected $allowedMimeTypes = [
            'audio/wave',
            'audio/caf',
    Severity: Minor
    Found in decode/MailParser.php - About 3 hrs to fix

      Function extractHeadersAndBody has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          private function extractHeadersAndBody()
          {
              $lines = \preg_split("/(\r?\n|\r)/", $this->raw);
      
              $currentHeader = '';
      Severity: Minor
      Found in decode/MailParser.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 getBody has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

          public function getBody(string $returnType = null)
          {
              $body = '';
              $detectedContentType = false;
              $contentTransferEncoding = null;
      Severity: Major
      Found in decode/MailParser.php - About 2 hrs to fix

        Method decode has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

            public function decode($attachment_directory = null, $saving = true)
            {
                if ($this->raw !== null) {
                    if (!empty($attachment_directory))
                        $this->attachment_directory = $attachment_directory;
        Severity: Minor
        Found in decode/MailParser.php - About 1 hr to fix

          Method decodePart has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Wontfix

              private function decodePart($body_part, $saving = true)
              {
                  if (isset($body_part->ctype_parameters) && \is_array($body_part->ctype_parameters)) {
                      if (\array_key_exists('name', $body_part->ctype_parameters)) {
                          $filename = $body_part->ctype_parameters['name'];
          Severity: Minor
          Found in decode/MailParser.php - About 1 hr to fix

            Function saveAttachment has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                private function saveAttachment($filename, $contents, $mime_type = 'unknown', $saving = true)
                {
                    $filename = \mb_convert_encoding($filename, $this->charset, $this->charset);
                    $dot_ext = '.' . $this->getFileExtension($filename);
                    $unlocked_and_unique = false;
            Severity: Minor
            Found in decode/MailParser.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 saveAttachment has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Wontfix

                private function saveAttachment($filename, $contents, $mime_type = 'unknown', $saving = true)
                {
                    $filename = \mb_convert_encoding($filename, $this->charset, $this->charset);
                    $dot_ext = '.' . $this->getFileExtension($filename);
                    $unlocked_and_unique = false;
            Severity: Minor
            Found in decode/MailParser.php - About 1 hr to fix

              Method extractHeadersAndBody has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Wontfix

                  private function extractHeadersAndBody()
                  {
                      $lines = \preg_split("/(\r?\n|\r)/", $this->raw);
              
                      $currentHeader = '';
              Severity: Minor
              Found in decode/MailParser.php - About 1 hr to fix

                There are no issues that match your filters.

                Category
                Status