PHPOffice/PHPPresentation

View on GitHub
src/PhpPresentation/Reader/ODPresentation.php

Summary

Maintainability
F
1 wk
Test Coverage
B
89%

Function loadStyle has a Cognitive Complexity of 119 (exceeds 5 allowed). Consider refactoring.
Open

    protected function loadStyle(DOMElement $nodeStyle): bool
    {
        $keyStyle = $nodeStyle->getAttribute('style:name');

        $nodeDrawingPageProps = $this->oXMLReader->getElement('style:drawing-page-properties', $nodeStyle);
Severity: Minor
Found in src/PhpPresentation/Reader/ODPresentation.php - About 2 days 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 ODPresentation.php has 596 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This file is part of PHPPresentation - A pure PHP library for reading and writing
 * presentations documents.
 *
Severity: Major
Found in src/PhpPresentation/Reader/ODPresentation.php - About 1 day to fix

    Method loadStyle has 230 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function loadStyle(DOMElement $nodeStyle): bool
        {
            $keyStyle = $nodeStyle->getAttribute('style:name');
    
            $nodeDrawingPageProps = $this->oXMLReader->getElement('style:drawing-page-properties', $nodeStyle);
    Severity: Major
    Found in src/PhpPresentation/Reader/ODPresentation.php - About 1 day to fix

      Function readParagraph has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): void
          {
              $oParagraph = $oShape->createParagraph();
              if ($oNodeParent->hasAttribute('text:style-name')) {
                  $keyStyle = $oNodeParent->getAttribute('text:style-name');
      Severity: Minor
      Found in src/PhpPresentation/Reader/ODPresentation.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

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

          protected function loadDocumentProperties(): void
          {
              $arrayProperties = [
                  '/office:document-meta/office:meta/meta:initial-creator' => 'setCreator',
                  '/office:document-meta/office:meta/dc:creator' => 'setLastModifiedBy',
      Severity: Minor
      Found in src/PhpPresentation/Reader/ODPresentation.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 loadDocumentProperties has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function loadDocumentProperties(): void
          {
              $arrayProperties = [
                  '/office:document-meta/office:meta/meta:initial-creator' => 'setCreator',
                  '/office:document-meta/office:meta/dc:creator' => 'setLastModifiedBy',
      Severity: Major
      Found in src/PhpPresentation/Reader/ODPresentation.php - About 2 hrs to fix

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

            protected function loadSlide(DOMElement $nodeSlide): bool
            {
                // Core
                $this->oPhpPresentation->createSlide();
                $this->oPhpPresentation->setActiveSlideIndex($this->oPhpPresentation->getSlideCount() - 1);
        Severity: Minor
        Found in src/PhpPresentation/Reader/ODPresentation.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 loadShapeDrawing has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function loadShapeDrawing(DOMElement $oNodeFrame): void
            {
                // Core
                $mimetype = '';
        
        
        Severity: Minor
        Found in src/PhpPresentation/Reader/ODPresentation.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 loadShapeDrawing has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function loadShapeDrawing(DOMElement $oNodeFrame): void
            {
                // Core
                $mimetype = '';
        
        
        Severity: Minor
        Found in src/PhpPresentation/Reader/ODPresentation.php - About 1 hr to fix

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

              protected function readParagraphItem(Paragraph $oParagraph, DOMElement $oNodeParent): void
              {
                  if ($this->oXMLReader->elementExists('text:line-break', $oNodeParent)) {
                      $oParagraph->createBreak();
                  } else {
          Severity: Minor
          Found in src/PhpPresentation/Reader/ODPresentation.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 readParagraph has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): void
              {
                  $oParagraph = $oShape->createParagraph();
                  if ($oNodeParent->hasAttribute('text:style-name')) {
                      $keyStyle = $oNodeParent->getAttribute('text:style-name');
          Severity: Minor
          Found in src/PhpPresentation/Reader/ODPresentation.php - About 1 hr to fix

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

                protected function loadShapeRichText(DOMElement $oNodeFrame): void
                {
                    // Core
                    $oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
                    $oShape->setParagraphs([]);
            Severity: Minor
            Found in src/PhpPresentation/Reader/ODPresentation.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 readList has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function readList(RichText $oShape, DOMElement $oNodeParent): void
                {
                    foreach ($this->oXMLReader->getElements('text:list-item/*', $oNodeParent) as $oNodeListItem) {
                        if ($oNodeListItem instanceof DOMElement) {
                            if ('text:p' == $oNodeListItem->nodeName) {
            Severity: Minor
            Found in src/PhpPresentation/Reader/ODPresentation.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 readListItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function readListItem(RichText $oShape, DOMElement $oNodeParent, DOMElement $oNodeParagraph): void
                {
                    $oParagraph = $oShape->createParagraph();
                    if ($oNodeParagraph->hasAttribute('text:style-name')) {
                        $keyStyle = $oNodeParagraph->getAttribute('text:style-name');
            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

            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

            There are no issues that match your filters.

            Category
            Status