File PowerPoint2007.php
has 1202 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.
*
Function loadParagraph
has a Cognitive Complexity of 138 (exceeds 5 allowed). Consider refactoring. Open
protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oShape): void
{
// Core
$oParagraph = $oShape->createParagraph();
$oParagraph->setRichTextElements([]);
- 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
Function loadShapeTable
has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring. Open
protected function loadShapeTable(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
{
$this->fileRels = $oSlide->getRelsIndex();
$oShape = $oSlide->createTableShape();
- 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
Function loadMasterSlide
has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring. Open
protected function loadMasterSlide(string $sPart, string $baseFile): 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
Function loadShapeDrawing
has a Cognitive Complexity of 44 (exceeds 5 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)) {
- 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 loadParagraph
has 166 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oShape): void
{
// Core
$oParagraph = $oShape->createParagraph();
$oParagraph->setRichTextElements([]);
Function loadSlide
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
protected function loadSlide(string $sPart, string $baseFile): 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
Function loadShapeRichText
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSlide): void
{
// Core
$oShape = $oSlide->createRichTextShape();
$oShape->setParagraphs([]);
- 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 loadShapeTable
has 124 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadShapeTable(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
{
$this->fileRels = $oSlide->getRelsIndex();
$oShape = $oSlide->createTableShape();
Function loadShadow
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
protected function loadShadow(XMLReader $document, DOMElement $node): ?Shadow
{
if ($node instanceof DOMElement) {
$aNodes = $document->getElements('*', $node);
foreach ($aNodes as $nodeShadow) {
- 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 loadMasterSlide
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadMasterSlide(string $sPart, string $baseFile): void
{
$xmlReader = new XMLReader();
// @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
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
PowerPoint2007
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class PowerPoint2007 implements ReaderInterface
{
/**
* Output Object.
*
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 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 loadShapeRichText
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSlide): void
{
// Core
$oShape = $oSlide->createRichTextShape();
$oShape->setParagraphs([]);
Method loadSlide
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadSlide(string $sPart, string $baseFile): void
{
$xmlReader = new XMLReader();
// @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
Function loadTheme
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function loadTheme(string $sPart, SlideMaster $oSlideMaster): 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
Function loadPresentationProperties
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function loadPresentationProperties(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
Function loadDocumentLayout
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function loadDocumentLayout(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 loadCustomProperties
has 39 lines of code (exceeds 25 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
Method loadSlideBackground
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadSlideBackground(XMLReader $xmlReader, DOMElement $oElement, AbstractSlide $oSlide): void
{
// Background color
$oElementColor = $xmlReader->getElement('p:bgPr/a:solidFill/a:srgbClr', $oElement);
if ($oElementColor instanceof DOMElement) {
Method loadShadow
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadShadow(XMLReader $document, DOMElement $node): ?Shadow
{
if ($node instanceof DOMElement) {
$aNodes = $document->getElements('*', $node);
foreach ($aNodes as $nodeShadow) {
Function loadSlideBackground
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function loadSlideBackground(XMLReader $xmlReader, DOMElement $oElement, AbstractSlide $oSlide): void
{
// Background color
$oElementColor = $xmlReader->getElement('p:bgPr/a:solidFill/a:srgbClr', $oElement);
if ($oElementColor instanceof DOMElement) {
- 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
Function loadDocumentProperties
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function loadDocumentProperties(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
Function loadSlideShapes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function loadSlideShapes($oSlide, DOMNodeList $oElements, XMLReader $xmlReader): void
{
foreach ($oElements as $oNode) {
if (!($oNode instanceof DOMElement)) {
continue;
- 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 loadFile
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadFile(string $pFilename): PhpPresentation
{
$this->oPhpPresentation = new PhpPresentation();
$this->oPhpPresentation->removeSlideByIndex();
$this->oPhpPresentation->setAllMasterSlides([]);
Function loadRels
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function loadRels(string $fileRels): void
{
$sPart = $this->oZip->getFromName($fileRels);
if (false !== $sPart) {
$xmlReader = new XMLReader();
- 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
Function loadStyleFill
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function loadStyleFill(XMLReader $xmlReader, DOMElement $oElement): ?Fill
{
// Gradient fill
$oElementFill = $xmlReader->getElement('a:gradFill', $oElement);
if ($oElementFill instanceof DOMElement) {
- 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
Function loadLayoutSlide
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function loadLayoutSlide(string $sPart, string $baseFile, SlideMaster $oSlideMaster): ?SlideLayout
{
$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 loadStyleFill
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadStyleFill(XMLReader $xmlReader, DOMElement $oElement): ?Fill
{
// Gradient fill
$oElementFill = $xmlReader->getElement('a:gradFill', $oElement);
if ($oElementFill instanceof DOMElement) {
Method loadDocumentProperties
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadDocumentProperties(string $sPart): void
{
$xmlReader = new XMLReader();
// @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
Method loadSlides
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadSlides(string $sPart): void
{
$xmlReader = new XMLReader();
// @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
Method loadPresentationProperties
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadPresentationProperties(string $sPart): void
{
$xmlReader = new XMLReader();
// @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
Method loadLayoutSlide
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadLayoutSlide(string $sPart, string $baseFile, SlideMaster $oSlideMaster): ?SlideLayout
{
$xmlReader = new XMLReader();
// @phpstan-ignore-next-line
if ($xmlReader->getDomFromString($sPart)) {
Function loadMasterSlides
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function loadMasterSlides(XMLReader $xmlReader, string $fileRels): void
{
// Get all the MasterSlide Id's from the presentation.xml file
foreach ($xmlReader->getElements('/p:presentation/p:sldMasterIdLst/p:sldMasterId') as $oElement) {
if (!($oElement instanceof DOMElement)) {
- 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
Avoid deeply nested control flow statements. Open
if ('..' == $partPath) {
unset($pathImage[$key - 1], $pathImage[$key]);
}
Avoid deeply nested control flow statements. Open
if (!$image) {
return;
}
Function loadViewProperties
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function loadViewProperties(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
Function loadFile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function loadFile(string $pFilename): PhpPresentation
{
$this->oPhpPresentation = new PhpPresentation();
$this->oPhpPresentation->removeSlideByIndex();
$this->oPhpPresentation->setAllMasterSlides([]);
- 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
Function loadStyleBorder
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function loadStyleBorder(XMLReader $xmlReader, DOMElement $oElement, Border $oBorder): void
{
if ($oElement->hasAttribute('w')) {
$oBorder->setLineWidth((int) ((int) $oElement->getAttribute('w') / 12700));
}
- 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
Function loadHyperlink
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function loadHyperlink(XMLReader $xmlReader, DOMElement $element, Hyperlink $hyperlink): Hyperlink
{
if ($element->hasAttribute('tooltip')) {
$hyperlink->setTooltip($element->getAttribute('tooltip'));
}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($oElementColor instanceof DOMElement) {
// Color
$oColor = new SchemeColor();
$oColor->setValue($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
// Background
- 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 92.
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 ($oElementColor instanceof DOMElement) {
// Color
$oColor = new Color();
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
// Background
- 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 92.
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