PHPOffice/PHPPresentation

View on GitHub
src/PhpPresentation/Writer/ODPresentation/Styles.php

Summary

Maintainability
C
1 day
Test Coverage
A
98%

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 writeRichTextStyle has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): void
        {
            $oFill = $shape->getFill();
            if (Fill::FILL_GRADIENT_LINEAR == $oFill->getFillType() || Fill::FILL_GRADIENT_PATH == $oFill->getFillType()) {
                if (!in_array($oFill->getHashCode(), $this->arrayGradient)) {
    Severity: Major
    Found in src/PhpPresentation/Writer/ODPresentation/Styles.php - About 3 hrs to fix

      Function writeRichTextStyle has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function writeRichTextStyle(XMLWriter $objWriter, RichText $shape): void
          {
              $oFill = $shape->getFill();
              if (Fill::FILL_GRADIENT_LINEAR == $oFill->getFillType() || Fill::FILL_GRADIENT_PATH == $oFill->getFillType()) {
                  if (!in_array($oFill->getHashCode(), $this->arrayGradient)) {
      Severity: Minor
      Found in src/PhpPresentation/Writer/ODPresentation/Styles.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 writePart has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function writePart(): string
          {
              // Create XML writer
              $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY);
              $objWriter->startDocument('1.0', 'UTF-8');
      Severity: Minor
      Found in src/PhpPresentation/Writer/ODPresentation/Styles.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 writeTableStyle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function writeTableStyle(XMLWriter $objWriter, Table $shape): void
          {
              foreach ($shape->getRows() as $row) {
                  foreach ($row->getCells() as $cell) {
                      if (Fill::FILL_GRADIENT_LINEAR == $cell->getFill()->getFillType()) {
      Severity: Minor
      Found in src/PhpPresentation/Writer/ODPresentation/Styles.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

      There are no issues that match your filters.

      Category
      Status