PHPOffice/PHPPresentation

View on GitHub

Showing 284 of 325 total issues

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

    protected function writeShapeGroup(XMLWriter $objWriter, Group $group): void
    {
        // draw:g
        $objWriter->startElement('draw:g');

Severity: Minor
Found in src/PhpPresentation/Writer/ODPresentation/Content.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

Avoid deeply nested control flow statements.
Open

                                    if ($element instanceof Run || $element instanceof TextElement) {
                                        if ($element->hasHyperlink()) {
                                            // Write relationship for hyperlink
                                            $hyperlink = $element->getHyperlink();
                                            $hyperlink->relationId = 'rId' . $relId;
Severity: Major
Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                    for ($cell = 0; $cell < $countCells; ++$cell) {
                                        $currentCell = $subShape->getRow($row)->getCell($cell);
                                        // Paragraphs in cell
                                        foreach ($currentCell->getParagraphs() as $paragraph) {
                                            // RichText in paragraph
    Severity: Major
    Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                              if ($element->hasHyperlink()) {
                                                  // Write relationship for hyperlink
                                                  $hyperlink = $element->getHyperlink();
                                                  $hyperlink->relationId = 'rId' . $relId;
      
      
      Severity: Major
      Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php - About 45 mins to fix

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

            public function save(string $pFilename): void
            {
                if (empty($pFilename)) {
                    throw new InvalidParameterException('pFilename', '');
                }
        Severity: Minor
        Found in src/PhpPresentation/Writer/Serialized.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

        Avoid deeply nested control flow statements.
        Open

                                    if (isset($clientTextbox['text' . $inc]['indent'])) {
                                        $indent = $clientTextbox['text' . $inc]['indent'];
                                    }
        Severity: Major
        Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (!$image) {
                                      return;
                                  }
          Severity: Major
          Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if (!empty($clientTextbox['hyperlink'])) {
                                            foreach ($clientTextbox['hyperlink'] as $itmHyperlink) {
                                                if ($itmHyperlink['start'] == $start && ($itmHyperlink['end'] - $itmHyperlink['start']) == (float) $clientTextbox['part' . $inc]['partLength']) {
                                                    $sText = $this->arrayHyperlinks[$itmHyperlink['id']]['text'];
                                                    $sHyperlinkURL = $this->arrayHyperlinks[$itmHyperlink['id']]['url'];
            Severity: Major
            Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                                  if ($this->currentNote > 0 && isset($arrayIdxSlide[$this->currentNote])) {
                                                      $oSlide = $this->oPhpPresentation->getSlide($arrayIdxSlide[$this->currentNote]);
                                                      if (0 == count($oSlide->getNote()->getShapeCollection())) {
                                                          $oSlide->getNote()->addShape($fileBlock['shape']);
                                                      }
              Severity: Major
              Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if (isset($clientTextbox['text' . $inc]['bulletChar'])) {
                                                $arrayReturn['shape']->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
                                                $arrayReturn['shape']->getActiveParagraph()->getBulletStyle()->setBulletChar($clientTextbox['text' . $inc]['bulletChar']);
                                            }
                Severity: Major
                Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if ($shadowOffsetX > 0 && $shadowOffsetX == $shadowOffsetY) {
                                                  $arrayReturn['shape']->getShadow()->setDistance($shadowOffsetX)->setDirection(45);
                                              }
                  Severity: Major
                  Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

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

                        private function readRecordOfficeArtClientData(string $stream, int $pos): array
                        {
                            $arrayReturn = [
                                'length' => 0,
                            ];
                    Severity: Minor
                    Found in src/PhpPresentation/Reader/PowerPoint97.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

                    Avoid deeply nested control flow statements.
                    Open

                                                if ('..' == $partPath) {
                                                    unset($pathImage[$key - 1], $pathImage[$key]);
                                                }
                    Severity: Major
                    Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if (isset($clientTextbox['text' . $inc]['leftMargin'])) {
                                                      if ($lastMarginLeft > $clientTextbox['text' . $inc]['leftMargin']) {
                                                          --$lastLevel;
                                                      }
                                                      if ($lastMarginLeft < $clientTextbox['text' . $inc]['leftMargin']) {
                      Severity: Major
                      Found in src/PhpPresentation/Reader/PowerPoint97.php - About 45 mins to fix

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

                            private function loadPicturesStream(): void
                            {
                                $stream = $this->streamPictures;
                        
                                $pos = 0;
                        Severity: Minor
                        Found in src/PhpPresentation/Reader/PowerPoint97.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 writeRelationship has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            protected function writeRelationship(XMLWriter $objWriter, int $pId, string $pType, string $pTarget, string $pTargetMode = ''): void
                        Severity: Minor
                        Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.php - About 35 mins to fix

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

                              protected function absoluteZipPath(string $path): string
                              {
                                  $path = str_replace([
                                      '/',
                                      '\\',
                          Severity: Minor
                          Found in src/PhpPresentation/Writer/PowerPoint2007/AbstractDecoratorWriter.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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function render(): ZipInterface
                              {
                                  $arrMedia = [];
                                  for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
                                      $shape = $this->getDrawingHashTable()->getByIndex($i);
                          Severity: Minor
                          Found in src/PhpPresentation/Writer/ODPresentation/Pictures.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 writeSpreadsheet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function writeSpreadsheet(PhpPresentation $presentation, Chart $chart, string $tempName): string
                              {
                                  // Create new spreadsheet
                                  $spreadsheet = new Spreadsheet();
                          
                          
                          Severity: Minor
                          Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.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 loadSlides has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function loadSlides(): void
                              {
                                  foreach ($this->oXMLReader->getElements('/office:document-content/office:automatic-styles/*') as $oElement) {
                                      if ($oElement instanceof DOMElement && $oElement->hasAttribute('style:name')) {
                                          $this->loadStyle($oElement);
                          Severity: Minor
                          Found in src/PhpPresentation/Reader/ODPresentation.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

                          Severity
                          Category
                          Status
                          Source
                          Language