barbushin/php-imap

View on GitHub

Showing 41 of 41 total issues

File Mailbox.php has 1092 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace PhpImap;
Severity: Major
Found in src/PhpImap/Mailbox.php - About 2 days to fix

    Mailbox has 90 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Mailbox
    {
    public const EXPECTED_SIZE_OF_MESSAGE_AS_ARRAY = 2;
     
    public const MAX_LENGTH_FILEPATH = 255;
    Severity: Major
    Found in src/PhpImap/Mailbox.php - About 1 day to fix

      File Imap.php has 694 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
      * @author Barbushin Sergey http://linkedin.com/in/barbushin
      * @author BAPCLTD-Marv
      */
      Severity: Major
      Found in src/PhpImap/Imap.php - About 1 day to fix

        Function initMailPart has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
        Open

        protected function initMailPart(IncomingMail $mail, object $partStructure, $partNum, bool $markAsSeen = true, bool $emlParse = false): void
        {
        if (!isset($mail->id)) {
        throw new InvalidArgumentException('Argument 1 passeed to '.__METHOD__.'() did not have the id property set!');
        }
        Severity: Minor
        Found in src/PhpImap/Mailbox.php - About 1 day to fix

        Function getMailHeader has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

        public function getMailHeader(int $mailId): IncomingMailHeader
        {
        $headersRaw = Imap::fetchheader(
        $this->getImapStream(),
        $mailId,
        Severity: Minor
        Found in src/PhpImap/Mailbox.php - About 6 hrs to fix

        Imap has 41 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class Imap
        {
        /** @psalm-var list<int> */
        public const SORT_CRITERIA = [
        SORTARRIVAL,
        Severity: Minor
        Found in src/PhpImap/Imap.php - About 5 hrs to fix

          Method getMailHeader has 123 lines of code (exceeds 40 allowed). Consider refactoring.
          Open

          public function getMailHeader(int $mailId): IncomingMailHeader
          {
          $headersRaw = Imap::fetchheader(
          $this->getImapStream(),
          $mailId,
          Severity: Major
          Found in src/PhpImap/Mailbox.php - About 4 hrs to fix

            Function getMailsInfo has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

            public function getMailsInfo(array $mailsIds): array
            {
            $mails = Imap::fetch_overview(
            $this->getImapStream(),
            \implode(',', $mailsIds),
            Severity: Minor
            Found in src/PhpImap/Mailbox.php - About 4 hrs to fix

            Method initMailPart has 95 lines of code (exceeds 40 allowed). Consider refactoring.
            Open

            protected function initMailPart(IncomingMail $mail, object $partStructure, $partNum, bool $markAsSeen = true, bool $emlParse = false): void
            {
            if (!isset($mail->id)) {
            throw new InvalidArgumentException('Argument 1 passeed to '.__METHOD__.'() did not have the id property set!');
            }
            Severity: Major
            Found in src/PhpImap/Mailbox.php - About 3 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              public static function mail_copy(
              $imap_stream,
              $msglist,
              string $mailbox,
              int $options = 0
              Severity: Major
              Found in src/PhpImap/Imap.php and 1 other location - About 3 hrs to fix
              src/PhpImap/Imap.php on lines 625..650

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              public static function mail_move(
              $imap_stream,
              $msglist,
              string $mailbox,
              int $options = 0
              Severity: Major
              Found in src/PhpImap/Imap.php and 1 other location - About 3 hrs to fix
              src/PhpImap/Imap.php on lines 592..617

              Function downloadAttachment has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              public function downloadAttachment(DataPartInfo $dataInfo, array $params, object $partStructure, bool $emlOrigin = false): IncomingMailAttachment
              {
              if ('RFC822' == $partStructure->subtype && isset($partStructure->disposition) && 'attachment' == $partStructure->disposition) {
              $fileName = \strtolower($partStructure->subtype).'.eml';
              } elseif ('ALTERNATIVE' == $partStructure->subtype) {
              Severity: Minor
              Found in src/PhpImap/Mailbox.php - About 2 hrs to fix

              Function embedImageAttachments has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              public function embedImageAttachments(): void
              {
              $fetchedHtml = $this->__get('textHtml');
               
              \preg_match_all("/\bcid:[^'\"\s]{1,256}/mi", $fetchedHtml, $matches);
              Severity: Minor
              Found in src/PhpImap/IncomingMail.php - About 2 hrs to fix

              Method downloadAttachment has 64 lines of code (exceeds 40 allowed). Consider refactoring.
              Open

              public function downloadAttachment(DataPartInfo $dataInfo, array $params, object $partStructure, bool $emlOrigin = false): IncomingMailAttachment
              {
              if ('RFC822' == $partStructure->subtype && isset($partStructure->disposition) && 'attachment' == $partStructure->disposition) {
              $fileName = \strtolower($partStructure->subtype).'.eml';
              } elseif ('ALTERNATIVE' == $partStructure->subtype) {
              Severity: Major
              Found in src/PhpImap/Mailbox.php - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                public static function setflag_full(
                $imap_stream,
                $sequence,
                string $flag,
                int $options = NIL
                Severity: Major
                Found in src/PhpImap/Imap.php and 1 other location - About 1 hr to fix
                src/PhpImap/Imap.php on lines 156..181

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                public static function clearflag_full(
                $imap_stream,
                $sequence,
                string $flag,
                int $options = 0
                Severity: Major
                Found in src/PhpImap/Imap.php and 1 other location - About 1 hr to fix
                src/PhpImap/Imap.php on lines 865..890

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

                public function setConnectionArgs(int $options = 0, int $retriesNum = 0, array $params = null): void
                {
                if (0 !== $options) {
                if (($options & self::IMAP_OPTIONS_SUPPORTED_VALUES) !== $options) {
                throw new InvalidParameterException('Please check your option for setConnectionArgs()! Unsupported option "'.$options.'". Available options: https://www.php.net/manual/de/function.imap-open.php');
                Severity: Minor
                Found in src/PhpImap/Mailbox.php - About 1 hr to fix

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

                protected function possiblyGetMailboxes(array $t): array
                {
                $arr = [];
                if ($t) {
                foreach ($t as $index => $item) {
                Severity: Minor
                Found in src/PhpImap/Mailbox.php - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                public static function subscribe($imap_stream, string $mailbox): void
                {
                $imap_stream = self::EnsureConnection($imap_stream, __METHOD__, 1);
                 
                $mailbox = static::encodeStringToUtf7Imap($mailbox);
                Severity: Major
                Found in src/PhpImap/Imap.php and 1 other location - About 1 hr to fix
                src/PhpImap/Imap.php on lines 1030..1045

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                public static function unsubscribe(
                $imap_stream,
                string $mailbox
                ): void {
                $imap_stream = self::EnsureConnection($imap_stream, __METHOD__, 1);
                Severity: Major
                Found in src/PhpImap/Imap.php and 1 other location - About 1 hr to fix
                src/PhpImap/Imap.php on lines 986..999
                Severity
                Category
                Status
                Source
                Language