diff --git a/src/PhpPresentation/HashTable.php b/src/PhpPresentation/HashTable.php index 4e8378ee6..54eec914d 100644 --- a/src/PhpPresentation/HashTable.php +++ b/src/PhpPresentation/HashTable.php @@ -79,13 +79,12 @@ public function add(ComparableInterface $pSource) { // Determine hashcode $hashIndex = $pSource->getHashIndex(); - + $hashCode = $pSource->getHashCode(); + if (is_null($hashIndex)) { $hashCode = $pSource->getHashCode(); } elseif (isset($this->keyMap[$hashIndex])) { $hashCode = $this->keyMap[$hashIndex]; - } else { - $hashCode = $pSource->getHashCode(); } // Add value diff --git a/src/PhpPresentation/PhpPresentation.php b/src/PhpPresentation/PhpPresentation.php index 580334289..241e0b8bf 100644 --- a/src/PhpPresentation/PhpPresentation.php +++ b/src/PhpPresentation/PhpPresentation.php @@ -223,9 +223,8 @@ public function removeSlideByIndex($index = 0) { if ($index > count($this->slideCollection) - 1) { throw new \Exception("Slide index is out of bounds."); - } else { - array_splice($this->slideCollection, $index, 1); } + array_splice($this->slideCollection, $index, 1); return $this; } @@ -241,9 +240,8 @@ public function getSlide($index = 0) { if ($index > count($this->slideCollection) - 1) { throw new \Exception("Slide index is out of bounds."); - } else { - return $this->slideCollection[$index]; } + return $this->slideCollection[$index]; } /** @@ -306,9 +304,8 @@ public function setActiveSlideIndex($index = 0) { if ($index > count($this->slideCollection) - 1) { throw new \Exception("Active slide index is out of bounds."); - } else { - $this->activeSlideIndex = $index; } + $this->activeSlideIndex = $index; return $this->getActiveSlide(); } diff --git a/src/PhpPresentation/Shape/RichText/Paragraph.php b/src/PhpPresentation/Shape/RichText/Paragraph.php index aa2bf79d8..ab64b706a 100644 --- a/src/PhpPresentation/Shape/RichText/Paragraph.php +++ b/src/PhpPresentation/Shape/RichText/Paragraph.php @@ -259,12 +259,10 @@ public function getRichTextElements() */ public function setRichTextElements($pElements = null) { - if (is_array($pElements)) { - $this->richTextElements = $pElements; - } else { + if (!is_array($pElements)) { throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\TextElementInterface[] array passed."); } - + $this->richTextElements = $pElements; return $this; } diff --git a/src/PhpPresentation/Shape/Table/Cell.php b/src/PhpPresentation/Shape/Table/Cell.php index 2307d0690..d06915da2 100644 --- a/src/PhpPresentation/Shape/Table/Cell.php +++ b/src/PhpPresentation/Shape/Table/Cell.php @@ -164,21 +164,18 @@ public function getParagraph($index = 0) public function createParagraph() { $this->richTextParagraphs[] = new Paragraph(); + $totalRichTextParagraphs = count($this->richTextParagraphs); + $this->activeParagraph = $totalRichTextParagraphs - 1; - if (count($this->richTextParagraphs) > 1) { + if ($totalRichTextParagraphs > 1) { $alignment = clone $this->getActiveParagraph()->getAlignment(); $font = clone $this->getActiveParagraph()->getFont(); $bulletStyle = clone $this->getActiveParagraph()->getBulletStyle(); - $this->activeParagraph = count($this->richTextParagraphs) - 1; - $this->getActiveParagraph()->setAlignment($alignment); $this->getActiveParagraph()->setFont($font); $this->getActiveParagraph()->setBulletStyle($bulletStyle); - } else { - $this->activeParagraph = count($this->richTextParagraphs) - 1; } - return $this->getActiveParagraph(); } @@ -279,13 +276,11 @@ public function getParagraphs() */ public function setParagraphs($paragraphs = null) { - if (is_array($paragraphs)) { - $this->richTextParagraphs = $paragraphs; - $this->activeParagraph = count($this->richTextParagraphs) - 1; - } else { + if (!is_array($paragraphs)) { throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed."); } - + $this->richTextParagraphs = $paragraphs; + $this->activeParagraph = count($this->richTextParagraphs) - 1; return $this; } diff --git a/src/PhpPresentation/Shape/Table/Row.php b/src/PhpPresentation/Shape/Table/Row.php index 4f427f02d..fb95d8df8 100644 --- a/src/PhpPresentation/Shape/Table/Row.php +++ b/src/PhpPresentation/Shape/Table/Row.php @@ -118,11 +118,9 @@ public function nextCell() $this->activeCellIndex++; if (isset($this->cells[$this->activeCellIndex])) { $this->cells[$this->activeCellIndex]->setFill(clone $this->getFill()); - return $this->cells[$this->activeCellIndex]; - } else { - throw new \Exception("Cell count out of bounds."); } + throw new \Exception("Cell count out of bounds."); } /** diff --git a/src/PhpPresentation/Writer/ODPresentation/Content.php b/src/PhpPresentation/Writer/ODPresentation/Content.php index ca0051de5..ad88a8b9e 100644 --- a/src/PhpPresentation/Writer/ODPresentation/Content.php +++ b/src/PhpPresentation/Writer/ODPresentation/Content.php @@ -484,8 +484,6 @@ public function writeShapeTxt(XMLWriter $objWriter, RichText $shape) $objWriter->startElement('text:line-break'); $objWriter->endElement(); $objWriter->endElement(); - } else { - //echo '
'.print_r($richtext, true).''; } } $objWriter->endElement(); @@ -549,8 +547,6 @@ public function writeShapeTxt(XMLWriter $objWriter, RichText $shape) $objWriter->startElement('text:line-break'); $objWriter->endElement(); $objWriter->endElement(); - } else { - //echo '
'.print_r($richtext, true).''; } } $objWriter->endElement();