PHPOffice/PHPPresentation

View on GitHub

Showing 325 of 325 total issues

File RichText.php has 323 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: Minor
Found in src/PhpPresentation/Shape/RichText.php - About 3 hrs to fix

    Method writePart has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function writePart(): string
        {
            // Create XML writer
            $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
            $objWriter->startDocument('1.0', 'UTF-8');
    Severity: Major
    Found in src/PhpPresentation/Writer/ODPresentation/Styles.php - About 3 hrs to fix

      Method readStructureTextCFRun has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function readStructureTextCFRun(string $stream, int $pos, int $strLenRT): array
          {
              $arrayReturn = [
                  'length' => 0,
                  'strLenRT' => $strLenRT,
      Severity: Major
      Found in src/PhpPresentation/Reader/PowerPoint97.php - About 3 hrs to fix

        DocumentProperties has 30 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class DocumentProperties
        {
            public const PROPERTY_TYPE_BOOLEAN = 'b';
            public const PROPERTY_TYPE_INTEGER = 'i';
            public const PROPERTY_TYPE_FLOAT = 'f';
        Severity: Minor
        Found in src/PhpPresentation/DocumentProperties.php - About 3 hrs to fix

          Method writeTypeDoughnut has 91 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bool $includeSheet = false): void
              {
                  // c:pieChart
                  $objWriter->startElement('c:doughnutChart');
          
          
          Severity: Major
          Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 3 hrs to fix

            Function loadSlides has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function loadSlides(string $sPart): void
                {
                    $xmlReader = new XMLReader();
                    // @phpstan-ignore-next-line
                    if ($xmlReader->getDomFromString($sPart)) {
            Severity: Minor
            Found in src/PhpPresentation/Reader/PowerPoint2007.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 writeTypeScatter has 88 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function writeTypeScatter(XMLWriter $objWriter, Scatter $subject, bool $includeSheet = false): void
                {
                    // c:scatterChart
                    $objWriter->startElement('c:scatterChart');
            
            
            Severity: Major
            Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 3 hrs to fix

              PowerPoint2007 has 29 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class PowerPoint2007 implements ReaderInterface
              {
                  /**
                   * Output Object.
                   *
              Severity: Minor
              Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 3 hrs to fix

                Method writeTxtStyle has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function writeTxtStyle(XMLWriter $objWriter, RichText $shape): void
                    {
                        // style:style
                        $objWriter->startElement('style:style');
                        $objWriter->writeAttribute('style:name', 'gr' . $this->shapeId);
                Severity: Major
                Found in src/PhpPresentation/Writer/ODPresentation/Content.php - About 3 hrs to fix

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

                      protected function loadCustomProperties(string $sPart): void
                      {
                          $xmlReader = new XMLReader();
                          $sPart = str_replace(' xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"', '', $sPart);
                          // @phpstan-ignore-next-line
                  Severity: Minor
                  Found in src/PhpPresentation/Reader/PowerPoint2007.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 writeTableStyle has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function writeTableStyle(XMLWriter $objWriter, Table $shape): void
                      {
                          foreach ($shape->getRows() as $keyRow => $shapeRow) {
                              // style:style
                              $objWriter->startElement('style:style');
                  Severity: Major
                  Found in src/PhpPresentation/Writer/ODPresentation/Content.php - About 3 hrs to fix

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

                                            if ($subShape instanceof RichText) {
                                                foreach ($subShape->getParagraphs() as $paragraph) {
                                                    foreach ($paragraph->getRichTextElements() as $element) {
                                                        if ($element instanceof Run || $element instanceof TextElement) {
                                                            if ($element->hasHyperlink()) {
                    Severity: Major
                    Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php and 1 other location - About 3 hrs to fix
                    src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php on lines 159..179

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 149.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

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

                                    if ($shape instanceof RichText) {
                                        foreach ($shape->getParagraphs() as $paragraph) {
                                            foreach ($paragraph->getRichTextElements() as $element) {
                                                if ($element instanceof Run || $element instanceof TextElement) {
                                                    if ($element->hasHyperlink()) {
                    Severity: Major
                    Found in src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php and 1 other location - About 3 hrs to fix
                    src/PhpPresentation/Writer/PowerPoint2007/PptSlides.php on lines 234..254

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 149.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Method writeTypePie has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includeSheet = false): void
                        {
                            // c:pieChart
                            $objWriter->startElement('c:pieChart');
                    
                    
                    Severity: Major
                    Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 3 hrs to fix

                      Method writeTypeLine has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function writeTypeLine(XMLWriter $objWriter, Line $subject, bool $includeSheet = false): void
                          {
                              // c:lineChart
                              $objWriter->startElement('c:lineChart');
                      
                      
                      Severity: Major
                      Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 3 hrs to fix

                        Method loadShapeDrawing has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function loadShapeDrawing(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
                            {
                                // Core
                                $document->registerNamespace('asvg', 'http://schemas.microsoft.com/office/drawing/2016/SVG/main');
                                if ($document->getElement('p:blipFill/a:blip/a:extLst/a:ext/asvg:svgBlip', $node)) {
                        Severity: Major
                        Found in src/PhpPresentation/Reader/PowerPoint2007.php - About 3 hrs to fix

                          Method writeTypeRadar has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function writeTypeRadar(XMLWriter $objWriter, Radar $subject, bool $includeSheet = false): void
                              {
                                  // c:scatterChart
                                  $objWriter->startElement('c:radarChart');
                          
                          
                          Severity: Major
                          Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 3 hrs to fix

                            Cell has 27 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class Cell implements ComparableInterface
                            {
                                /**
                                 * Rich text paragraphs.
                                 *
                            Severity: Minor
                            Found in src/PhpPresentation/Shape/Table/Cell.php - About 3 hrs to fix

                              Paragraph has 27 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              class Paragraph implements ComparableInterface
                              {
                                  public const LINE_SPACING_MODE_PERCENT = 'percent';
                                  public const LINE_SPACING_MODE_POINT = 'point';
                              
                              
                              Severity: Minor
                              Found in src/PhpPresentation/Shape/RichText/Paragraph.php - About 3 hrs to fix

                                Method writeTypePie3D has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $includeSheet = false): void
                                    {
                                        // c:pie3DChart
                                        $objWriter->startElement('c:pie3DChart');
                                
                                
                                Severity: Major
                                Found in src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php - About 3 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language