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.
*
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');
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,
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';
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');
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)) {
- Read upRead up
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');
PowerPoint2007
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class PowerPoint2007 implements ReaderInterface
{
/**
* Output Object.
*
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);
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
- Read upRead up
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');
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()) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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()) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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');
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');
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)) {
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');
Cell
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Cell implements ComparableInterface
{
/**
* Rich text paragraphs.
*
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';
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');