From c21e28f9744cf25be7d643cdaf3fb28470d917a5 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Sun, 4 May 2014 15:13:31 +0700 Subject: [PATCH] More refactoring for PHPMD compliance --- .travis.yml | 7 +- CHANGELOG.md | 1 + phpmd.xml | 14 -- src/PhpWord/Element/AbstractContainer.php | 142 ++++++++-------- src/PhpWord/Element/AbstractElement.php | 4 +- src/PhpWord/Element/Footer.php | 2 +- src/PhpWord/Element/Image.php | 54 +++++-- src/PhpWord/Element/Object.php | 61 ++++--- src/PhpWord/Element/Title.php | 17 +- src/PhpWord/Footnotes.php | 151 ------------------ src/PhpWord/Media.php | 2 +- src/PhpWord/Reader/AbstractReader.php | 13 +- src/PhpWord/Settings.php | 39 +++-- src/PhpWord/Shared/Drawing.php | 80 +++++----- src/PhpWord/Shared/XMLWriter.php | 2 +- src/PhpWord/Style/Font.php | 71 +++++++- src/PhpWord/Style/Paragraph.php | 84 +++++++--- src/PhpWord/Style/Row.php | 61 +++++-- src/PhpWord/Style/TOC.php | 4 +- src/PhpWord/Style/Table.php | 16 +- src/PhpWord/TOC.php | 84 ---------- src/PhpWord/Writer/AbstractWriter.php | 19 ++- src/PhpWord/Writer/HTML/Style/Font.php | 10 +- src/PhpWord/Writer/ODText/Element/Text.php | 8 +- src/PhpWord/Writer/ODText/Style/Font.php | 4 +- src/PhpWord/Writer/RTF/Element/Text.php | 8 +- src/PhpWord/Writer/Word2007/Element/Image.php | 2 +- src/PhpWord/Writer/Word2007/Element/Table.php | 11 +- .../Writer/Word2007/Part/AbstractPart.php | 2 +- .../Writer/Word2007/Part/ContentTypes.php | 24 +-- src/PhpWord/Writer/Word2007/Style/Font.php | 16 +- .../Writer/Word2007/Style/Paragraph.php | 13 +- tests/PhpWord/Tests/Element/ImageTest.php | 4 +- tests/PhpWord/Tests/SettingsTest.php | 4 +- tests/PhpWord/Tests/Shared/DrawingTest.php | 2 +- tests/PhpWord/Tests/Writer/ODTextTest.php | 2 +- tests/PhpWord/Tests/Writer/Word2007Test.php | 2 +- 37 files changed, 492 insertions(+), 548 deletions(-) delete mode 100644 phpmd.xml delete mode 100644 src/PhpWord/Footnotes.php delete mode 100644 src/PhpWord/TOC.php diff --git a/.travis.yml b/.travis.yml index cf69291f..10cb442f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,12 +38,11 @@ before_script: script: ## PHP_CodeSniffer - - phpcs --standard=PSR2 -n src/ --ignore=src/PhpWord/Shared/PCLZip - - phpcs --standard=PSR2 -n tests/ + - phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ## PHP Copy/Paste Detector - - php phpcpd.phar --verbose src/ + - phpcpd src/ tests/ --verbose ## PHP Mess Detector - - phpmd src/ text phpmd.xml --exclude pclzip.lib.php + - phpmd src/ text unusedcode,naming,design,controversial --exclude pclzip.lib.php ## PHPLOC #- php phploc.phar src/ ## PHPUnit diff --git a/CHANGELOG.md b/CHANGELOG.md index ccdac7ee..b3b70dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ This release marked heavy refactorings on internal code structure with the creat - Refactor: Apply composite pattern for Word2007 reader - @ivanlanin - Refactor: Replace static classes `Footnotes`, `Endnotes`, and `TOC` with `Collections` - @ivanlanin GH-206 - QA: Reactivate `phpcpd` and `phpmd` on Travis - @ivanlanin +- Refactor: PHPMD recommendation: Change all `get...` method that returns `boolean` into `is...` or `has...` - @ivanlanin ## 0.9.1 - 27 Mar 2014 diff --git a/phpmd.xml b/phpmd.xml deleted file mode 100644 index c1ebb770..00000000 --- a/phpmd.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 0968c4ff..6c277dad 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -9,17 +9,15 @@ namespace PhpOffice\PhpWord\Element; +use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Element\CheckBox; use PhpOffice\PhpWord\Element\Image; use PhpOffice\PhpWord\Element\Link; use PhpOffice\PhpWord\Element\ListItem; use PhpOffice\PhpWord\Element\Object; -use PhpOffice\PhpWord\Element\PreserveText; -use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\TextBreak; use PhpOffice\PhpWord\Element\TextRun; -use PhpOffice\PhpWord\Exception\InvalidObjectException; /** * Container abstract class @@ -69,27 +67,29 @@ abstract class AbstractContainer extends AbstractElement } /** - * Add text element + * Add text/preservetext element * * @param string $text * @param mixed $fontStyle * @param mixed $paragraphStyle - * @return \PhpOffice\PhpWord\Element\Text + * @param string $elementName Text|PreserveText + * @return \PhpOffice\PhpWord\Element\Text|\PhpOffice\PhpWord\Element\PreserveText */ - public function addText($text, $fontStyle = null, $paragraphStyle = null) + public function addText($text, $fontStyle = null, $paragraphStyle = null, $elementName = 'Text') { - $this->checkValidity('Text'); + $this->checkValidity($elementName); + $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; // Reset paragraph style for footnote and textrun. They have their own if (in_array($this->container, array('textrun', 'footnote', 'endnote'))) { $paragraphStyle = null; } - $textObject = new Text($text, $fontStyle, $paragraphStyle); - $textObject->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textObject); + $element = new $elementClass($text, $fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $textObject; + return $element; } /** @@ -102,11 +102,11 @@ abstract class AbstractContainer extends AbstractElement { $this->checkValidity('Textrun'); - $textRun = new TextRun($paragraphStyle); - $textRun->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textRun); + $element = new TextRun($paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $textRun; + return $element; } /** @@ -123,13 +123,15 @@ abstract class AbstractContainer extends AbstractElement $this->checkValidity('Link'); $elementDocPart = $this->checkElementDocPart(); - $link = new Link($target, $text, $fontStyle, $paragraphStyle); - $link->setDocPart($this->getDocPart(), $this->getDocPartId()); - $rId = Media::addElement($elementDocPart, 'link', $target); - $link->setRelationId($rId); - $this->addElement($link); + $element = new Link($target, $text, $fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - return $link; + $rId = Media::addElement($elementDocPart, 'link', $target); + $element->setRelationId($rId); + + $this->addElement($element); + + return $element; } /** @@ -142,13 +144,7 @@ abstract class AbstractContainer extends AbstractElement */ public function addPreserveText($text, $fontStyle = null, $paragraphStyle = null) { - $this->checkValidity('PreserveText'); - - $preserveText = new PreserveText($text, $fontStyle, $paragraphStyle); - $preserveText->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($preserveText); - - return $preserveText; + return $this->addText($text, $fontStyle, $paragraphStyle, 'PreserveText'); } /** @@ -163,9 +159,9 @@ abstract class AbstractContainer extends AbstractElement $this->checkValidity('TextBreak'); for ($i = 1; $i <= $count; $i++) { - $textBreak = new TextBreak($fontStyle, $paragraphStyle); - $textBreak->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($textBreak); + $element = new TextBreak($fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); } } @@ -183,33 +179,35 @@ abstract class AbstractContainer extends AbstractElement { $this->checkValidity('ListItem'); - $listItem = new ListItem($text, $depth, $fontStyle, $listStyle, $paragraphStyle); - $listItem->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($listItem); + $element = new ListItem($text, $depth, $fontStyle, $listStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $listItem; + return $element; } /** * Add image element * - * @param string $src + * @param string $source * @param mixed $style Image style * @param boolean $isWatermark * @return \PhpOffice\PhpWord\Element\Image */ - public function addImage($src, $style = null, $isWatermark = false) + public function addImage($source, $style = null, $isWatermark = false) { $this->checkValidity('Image'); $elementDocPart = $this->checkElementDocPart(); - $image = new Image($src, $style, $isWatermark); - $image->setDocPart($this->getDocPart(), $this->getDocPartId()); - $rId = Media::addElement($elementDocPart, 'image', $src, $image); - $image->setRelationId($rId); - $this->addElement($image); + $element = new Image($source, $style, $isWatermark); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - return $image; + $rId = Media::addElement($elementDocPart, 'image', $source, $element); + $element->setRelationId($rId); + + $this->addElement($element); + + return $element; } /** @@ -217,35 +215,27 @@ abstract class AbstractContainer extends AbstractElement * * All exceptions should be handled by \PhpOffice\PhpWord\Element\Object * - * @param string $src + * @param string $source * @param mixed $style * @return \PhpOffice\PhpWord\Element\Object * @throws \PhpOffice\PhpWord\Exception\Exception */ - public function addObject($src, $style = null) + public function addObject($source, $style = null) { $this->checkValidity('Object'); $elementDocPart = $this->checkElementDocPart(); - $object = new Object($src, $style); - $object->setDocPart($this->getDocPart(), $this->getDocPartId()); - if (!is_null($object->getSource())) { - $inf = pathinfo($src); - $ext = $inf['extension']; - if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { - $ext = substr($ext, 0, -1); - } - $icon = realpath(__DIR__ . "/../resources/{$ext}.png"); - $rId = Media::addElement($elementDocPart, 'object', $src); - $object->setRelationId($rId); - $rIdimg = Media::addElement($elementDocPart, 'image', $icon, new Image($icon)); - $object->setImageRelationId($rIdimg); - $this->addElement($object); + $element = new Object($source, $style); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); - return $object; - } else { - throw new InvalidObjectException(); - } + $rId = Media::addElement($elementDocPart, 'object', $source); + $element->setRelationId($rId); + $rIdIcon = Media::addElement($elementDocPart, 'image', $element->getIcon(), new Image($element->getIcon())); + $element->setImageRelationId($rIdIcon); + + $this->addElement($element); + + return $element; } /** @@ -258,19 +248,19 @@ abstract class AbstractContainer extends AbstractElement public function addFootnote($paragraphStyle = null, $elementName = 'Footnote') { $this->checkValidity($elementName); + $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; $docPart = strtolower($elementName); $addMethod = "add{$elementName}"; - $elementClass = 'PhpOffice\\PhpWord\\Element\\' . $elementName; - $note = new $elementClass($paragraphStyle); - // if ($this->phpWord instanceof PhpWord) { - $rId = $this->phpWord->$addMethod($note); - // } - $note->setDocPart($docPart, $this->getDocPartId()); - $note->setRelationId($rId); - $this->addElement($note); + $element = new $elementClass($paragraphStyle); + if ($this->phpWord instanceof PhpWord) { + $rId = $this->phpWord->$addMethod($element); + } + $element->setDocPart($docPart, $this->getDocPartId()); + $element->setRelationId($rId); + $this->addElement($element); - return $note; + return $element; } /** @@ -297,11 +287,11 @@ abstract class AbstractContainer extends AbstractElement { $this->checkValidity('CheckBox'); - $checkBox = new CheckBox($name, $text, $fontStyle, $paragraphStyle); - $checkBox->setDocPart($this->getDocPart(), $this->getDocPartId()); - $this->addElement($checkBox); + $element = new CheckBox($name, $text, $fontStyle, $paragraphStyle); + $element->setDocPart($this->getDocPart(), $this->getDocPartId()); + $this->addElement($element); - return $checkBox; + return $element; } /** diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index fdad7daf..ce83a2cb 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -92,13 +92,13 @@ abstract class AbstractElement } /** - * Set PhpWord + * Set PhpWord as reference * * @param \PhpOffice\PhpWord\PhpWord */ public function setPhpWord(PhpWord &$phpWord = null) { - $this->phpWord = $phpWord; + $this->phpWord = &$phpWord; } /** diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 9090720d..349b59aa 100644 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -44,7 +44,7 @@ class Footer extends AbstractContainer * Create new instance * * @param int $sectionId - * @param int $footerId + * @param int $containerId * @param string $type */ public function __construct($sectionId, $containerId = 1, $type = self::AUTO) diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 53becbbf..ec120cae 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -52,7 +52,7 @@ class Image extends AbstractElement * * @var boolean */ - private $isWatermark; + private $watermark; /** * Image type @@ -87,7 +87,7 @@ class Image extends AbstractElement * * @var boolean */ - private $isMemImage; + private $memoryImage; /** * Image target file name @@ -108,14 +108,14 @@ class Image extends AbstractElement * * @param string $source * @param mixed $style - * @param boolean $isWatermark + * @param boolean $watermark * @throws \PhpOffice\PhpWord\Exception\InvalidImageException * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException */ - public function __construct($source, $style = null, $isWatermark = false) + public function __construct($source, $style = null, $watermark = false) { $this->source = $source; - $this->setIsWatermark($isWatermark); + $this->setIsWatermark($watermark); $this->style = $this->setStyle(new ImageStyle(), $style, true); $this->checkImage($source); @@ -166,19 +166,19 @@ class Image extends AbstractElement * * @return boolean */ - public function getIsWatermark() + public function isWatermark() { - return $this->isWatermark; + return $this->watermark; } /** * Set is watermark * - * @param boolean $pValue + * @param boolean $value */ - public function setIsWatermark($pValue) + public function setIsWatermark($value) { - $this->isWatermark = $pValue; + $this->watermark = $value; } /** @@ -226,9 +226,9 @@ class Image extends AbstractElement * * @return boolean */ - public function getIsMemImage() + public function isMemImage() { - return $this->isMemImage; + return $this->memoryImage; } /** @@ -314,14 +314,14 @@ class Image extends AbstractElement private function setSourceType($source) { if (stripos(strrev($source), strrev('.php')) === 0) { - $this->isMemImage = true; + $this->memoryImage = true; $this->sourceType = self::SOURCE_GD; } elseif (strpos($source, 'zip://') !== false) { - $this->isMemImage = false; + $this->memoryImage = false; $this->sourceType = self::SOURCE_ARCHIVE; } else { - $this->isMemImage = (filter_var($source, FILTER_VALIDATE_URL) !== false); - $this->sourceType = $this->isMemImage ? self::SOURCE_GD : self::SOURCE_LOCAL; + $this->memoryImage = (filter_var($source, FILTER_VALIDATE_URL) !== false); + $this->sourceType = $this->memoryImage ? self::SOURCE_GD : self::SOURCE_LOCAL; } } @@ -409,4 +409,26 @@ class Image extends AbstractElement } } } + + /** + * Get is watermark + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getIsWatermark() + { + return $this->isWatermark(); + } + + /** + * Get is memory image + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getIsMemImage() + { + return $this->isMemImage(); + } } diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index 7407688a..c2d204cc 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -10,6 +10,7 @@ namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Style\Image as ImageStyle; +use PhpOffice\PhpWord\Exception\InvalidObjectException; /** * Object element @@ -30,6 +31,13 @@ class Object extends AbstractElement */ private $style; + /** + * Icon + * + * @var string + */ + private $icon; + /** * Image Relation ID * @@ -40,35 +48,32 @@ class Object extends AbstractElement /** * Create a new Ole-Object Element * - * @param string $src + * @param string $source * @param mixed $style */ - public function __construct($src, $style = null) + public function __construct($source, $style = null) { $supportedTypes = array('xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx'); - $inf = pathinfo($src); + $pathInfo = pathinfo($source); - if (file_exists($src) && in_array($inf['extension'], $supportedTypes)) { - $this->source = $src; + if (file_exists($source) && in_array($pathInfo['extension'], $supportedTypes)) { + $ext = $pathInfo['extension']; + if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') { + $ext = substr($ext, 0, -1); + } + + $this->source = $source; $this->style = $this->setStyle(new ImageStyle(), $style, true); + $this->icon = realpath(__DIR__ . "/../resources/{$ext}.png"); + return $this; } else { - return false; + throw new InvalidObjectException(); } } /** - * Get Image style - * - * @return \PhpOffice\PhpWord\Style\Image - */ - public function getStyle() - { - return $this->style; - } - - /** - * Get Source + * Get object source * * @return string */ @@ -78,7 +83,27 @@ class Object extends AbstractElement } /** - * Get Image Relation ID + * Get object style + * + * @return \PhpOffice\PhpWord\Style\Image + */ + public function getStyle() + { + return $this->style; + } + + /** + * Get object icon + * + * @return string + */ + public function getIcon() + { + return $this->icon; + } + + /** + * Get image relation ID * * @return int */ diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index f6d3bba9..d07df480 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -29,14 +29,7 @@ class Title extends AbstractElement * * @var int */ - private $depth; - - /** - * Title anchor - * - * @var int - */ - private $anchor; + private $depth = 1; /** * Title Bookmark ID @@ -52,13 +45,19 @@ class Title extends AbstractElement */ private $style; + /** + * Title anchor + * + * @var int + * @deprecated 0.10.0 + */ + private $anchor; /** * Create a new Title Element * * @param string $text * @param int $depth - * @param string $style */ public function __construct($text, $depth = 1) { diff --git a/src/PhpWord/Footnotes.php b/src/PhpWord/Footnotes.php deleted file mode 100644 index 7ab2a587..00000000 --- a/src/PhpWord/Footnotes.php +++ /dev/null @@ -1,151 +0,0 @@ -getIsMemImage(); + $isMemImage = $image->isMemImage(); $extension = $image->getImageExtension(); $mediaData['imageExtension'] = $extension; $mediaData['imageType'] = $image->getImageType(); diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index 424ff2cd..2eb53fe2 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -37,7 +37,7 @@ abstract class AbstractReader implements ReaderInterface * * @return bool */ - public function getReadDataOnly() + public function isReadDataOnly() { // return $this->readDataOnly; return true; @@ -96,4 +96,15 @@ abstract class AbstractReader implements ReaderInterface return true; } + + /** + * Read data only? + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getReadDataOnly() + { + return $this->isReadDataOnly(); + } } diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index bd18df48..af9044d3 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -91,6 +91,16 @@ class Settings */ private static $measurementUnit = self::UNIT_TWIP; + /** + * Return the compatibility option used by the XMLWriter + * + * @return bool Compatibility + */ + public static function hasCompatibility() + { + return self::$xmlWriterCompatibility; + } + /** * Set the compatibility option used by the XMLWriter * @@ -110,13 +120,13 @@ class Settings } /** - * Return the compatibility option used by the XMLWriter + * Get zip handler class * - * @return bool Compatibility + * @return string */ - public static function getCompatibility() + public static function getZipClass() { - return self::$xmlWriterCompatibility; + return self::$zipClass; } /** @@ -136,16 +146,6 @@ class Settings return false; } - /** - * Get zip handler class - * - * @return string - */ - public static function getZipClass() - { - return self::$zipClass; - } - /** * Set details of the external library for rendering PDF files * @@ -237,4 +237,15 @@ class Settings return true; } + + /** + * Return the compatibility option used by the XMLWriter + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public static function getCompatibility() + { + return self::hasCompatibility(); + } } diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 58a6ee1a..3d754469 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -17,24 +17,24 @@ class Drawing /** * Convert pixels to EMU * - * @param integer $pValue Value in pixels + * @param integer $value Value in pixels * @return double Value in EMU */ - public static function pixelsToEMU($pValue = 0) + public static function pixelsToEMU($value = 0) { - return round($pValue * 9525); + return round($value * 9525); } /** * Convert EMU to pixels * - * @param integer $pValue Value in EMU + * @param integer $value Value in EMU * @return integer Value in pixels */ - public static function EMUToPixels($pValue = 0) + public static function emuToPixels($value = 0) { - if ($pValue != 0) { - return round($pValue / 9525); + if ($value != 0) { + return round($value / 9525); } else { return 0; } @@ -43,24 +43,24 @@ class Drawing /** * Convert pixels to points * - * @param integer $pValue Value in pixels + * @param integer $value Value in pixels * @return double Value in points */ - public static function pixelsToPoints($pValue = 0) + public static function pixelsToPoints($value = 0) { - return $pValue * 0.67777777; + return $value * 0.67777777; } /** * Convert points width to pixels * - * @param integer $pValue Value in points + * @param integer $value Value in points * @return integer Value in pixels */ - public static function pointsToPixels($pValue = 0) + public static function pointsToPixels($value = 0) { - if ($pValue != 0) { - return $pValue * 1.333333333; + if ($value != 0) { + return $value * 1.333333333; } else { return 0; } @@ -69,24 +69,24 @@ class Drawing /** * Convert degrees to angle * - * @param integer $pValue Degrees + * @param integer $value Degrees * @return integer Angle */ - public static function degreesToAngle($pValue = 0) + public static function degreesToAngle($value = 0) { - return (integer)round($pValue * 60000); + return (integer)round($value * 60000); } /** * Convert angle to degrees * - * @param integer $pValue Angle + * @param integer $value Angle * @return integer Degrees */ - public static function angleToDegrees($pValue = 0) + public static function angleToDegrees($value = 0) { - if ($pValue != 0) { - return round($pValue / 60000); + if ($value != 0) { + return round($value / 60000); } else { return 0; } @@ -95,24 +95,24 @@ class Drawing /** * Convert pixels to centimeters * - * @param integer $pValue Value in pixels + * @param integer $value Value in pixels * @return double Value in centimeters */ - public static function pixelsToCentimeters($pValue = 0) + public static function pixelsToCentimeters($value = 0) { - return $pValue * 0.028; + return $value * 0.028; } /** * Convert centimeters width to pixels * - * @param integer $pValue Value in centimeters + * @param integer $value Value in centimeters * @return integer Value in pixels */ - public static function centimetersToPixels($pValue = 0) + public static function centimetersToPixels($value = 0) { - if ($pValue != 0) { - return $pValue / 0.028; + if ($value != 0) { + return $value / 0.028; } else { return 0; } @@ -121,27 +121,27 @@ class Drawing /** * Convert HTML hexadecimal to RGB * - * @param string $pValue HTML Color in hexadecimal + * @param string $value HTML Color in hexadecimal * @return array Value in RGB */ - public static function htmlToRGB($pValue) + public static function htmlToRGB($value) { - if ($pValue[0] == '#') { - $pValue = substr($pValue, 1); + if ($value[0] == '#') { + $value = substr($value, 1); } - if (strlen($pValue) == 6) { - list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]); - } elseif (strlen($pValue) == 3) { - list($color_R, $color_G, $color_B) = array($pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]); + if (strlen($value) == 6) { + list($red, $green, $blue) = array($value[0] . $value[1], $value[2] . $value[3], $value[4] . $value[5]); + } elseif (strlen($value) == 3) { + list($red, $green, $blue) = array($value[0] . $value[0], $value[1] . $value[1], $value[2] . $value[2]); } else { return false; } - $color_R = hexdec($color_R); - $color_G = hexdec($color_G); - $color_B = hexdec($color_B); + $red = hexdec($red); + $green = hexdec($green); + $blue = hexdec($blue); - return array($color_R, $color_G, $color_B); + return array($red, $green, $blue); } } diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 53f5e893..876053a7 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -73,7 +73,7 @@ class XMLWriter } // Set xml Compatibility - $compatibility = Settings::getCompatibility(); + $compatibility = Settings::hasCompatibility(); if ($compatibility) { $this->xmlWriter->setIndent(false); $this->xmlWriter->setIndentString(''); diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index 86467d02..ce6882cb 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -288,7 +288,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getBold() + public function isBold() { return $this->bold; } @@ -311,7 +311,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getItalic() + public function isItalic() { return $this->italic; } @@ -334,7 +334,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getSuperScript() + public function isSuperScript() { return $this->superScript; } @@ -360,7 +360,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getSubScript() + public function isSubScript() { return $this->subScript; } @@ -409,7 +409,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getStrikethrough() + public function isStrikethrough() { return $this->strikethrough; } @@ -435,7 +435,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getDoubleStrikethrough() + public function isDoubleStrikethrough() { return $this->doubleStrikethrough; } @@ -605,7 +605,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getSmallCaps() + public function isSmallCaps() { return $this->smallCaps; } @@ -631,7 +631,7 @@ class Font extends AbstractStyle * * @return bool */ - public function getAllCaps() + public function isAllCaps() { return $this->allCaps; } @@ -681,4 +681,59 @@ class Font extends AbstractStyle return $this; } + + /** + * Get bold + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getBold() + { + return $this->isBold(); + } + + /** + * Get italic + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getItalic() + { + return $this->isItalic(); + } + + /** + * Get superscript + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getSuperScript() + { + return $this->isSuperScript(); + } + + /** + * Get subscript + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getSubScript() + { + return $this->isSubScript(); + } + + /** + * Get strikethrough + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getStrikethrough() + { + return $this->isStrikethrough(); + } } diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index b6f482bf..0a1be26b 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -340,7 +340,7 @@ class Paragraph extends AbstractStyle /** * Get parent style ID * - * @return string + * @return string */ public function getBasedOn() { @@ -350,8 +350,8 @@ class Paragraph extends AbstractStyle /** * Set parent style ID * - * @param string $value - * @return self + * @param string $value + * @return self */ public function setBasedOn($value = 'Normal') { @@ -372,8 +372,8 @@ class Paragraph extends AbstractStyle /** * Set style for next paragraph * - * @param string $value - * @return self + * @param string $value + * @return self */ public function setNext($value = null) { @@ -384,9 +384,9 @@ class Paragraph extends AbstractStyle /** * Get allow first/last line to display on a separate page setting * - * @return bool + * @return bool */ - public function getWidowControl() + public function hasWidowControl() { return $this->widowControl; } @@ -394,8 +394,8 @@ class Paragraph extends AbstractStyle /** * Set keep paragraph with next paragraph setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setWidowControl($value = true) { @@ -409,9 +409,9 @@ class Paragraph extends AbstractStyle /** * Get keep paragraph with next paragraph setting * - * @return bool + * @return bool */ - public function getKeepNext() + public function isKeepNext() { return $this->keepNext; } @@ -419,8 +419,8 @@ class Paragraph extends AbstractStyle /** * Set keep paragraph with next paragraph setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setKeepNext($value = false) { @@ -434,9 +434,9 @@ class Paragraph extends AbstractStyle /** * Get keep all lines on one page setting * - * @return bool + * @return bool */ - public function getKeepLines() + public function isKeepLines() { return $this->keepLines; } @@ -444,8 +444,8 @@ class Paragraph extends AbstractStyle /** * Set keep all lines on one page setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setKeepLines($value = false) { @@ -461,7 +461,7 @@ class Paragraph extends AbstractStyle * * @return bool */ - public function getPageBreakBefore() + public function hasPageBreakBefore() { return $this->pageBreakBefore; } @@ -469,8 +469,8 @@ class Paragraph extends AbstractStyle /** * Set start paragraph on next page setting * - * @param bool $value - * @return self + * @param bool $value + * @return self */ public function setPageBreakBefore($value = false) { @@ -542,4 +542,48 @@ class Paragraph extends AbstractStyle return $this; } + + /** + * Get allow first/last line to display on a separate page setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getWidowControl() + { + return $this->hasWidowControl(); + } + + /** + * Get keep paragraph with next paragraph setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getKeepNext() + { + return $this->isKeepNext(); + } + + /** + * Get keep all lines on one page setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getKeepLines() + { + return $this->isKeepLines(); + } + + /** + * Get start paragraph on next page setting + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getPageBreakBefore() + { + return $this->hasPageBreakBefore(); + } } diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index e2a07b85..727ad221 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -45,9 +45,19 @@ class Row extends AbstractStyle } /** - * Set tblHeader + * Is tblHeader * - * @param boolean $value + * @return bool + */ + public function isTblHeader() + { + return $this->tblHeader; + } + + /** + * Is tblHeader + * + * @param bool $value * @return self */ public function setTblHeader($value = false) @@ -56,19 +66,19 @@ class Row extends AbstractStyle } /** - * Get tblHeader + * Is cantSplit * - * @return boolean + * @return bool */ - public function getTblHeader() + public function isCantSplit() { - return $this->tblHeader; + return $this->cantSplit; } /** - * Set cantSplit + * Is cantSplit * - * @param boolean $value + * @param bool $value * @return self */ public function setCantSplit($value = false) @@ -77,13 +87,13 @@ class Row extends AbstractStyle } /** - * Get cantSplit + * Is exactHeight * - * @return boolean + * @return bool */ - public function getCantSplit() + public function isExactHeight() { - return $this->cantSplit; + return $this->exactHeight; } /** @@ -98,13 +108,36 @@ class Row extends AbstractStyle return $this; } + /** + * Get tblHeader + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getTblHeader() + { + return $this->isTblHeader(); + } + + /** + * Get cantSplit + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getCantSplit() + { + return $this->isCantSplit(); + } + /** * Get exactHeight * - * @return boolean + * @deprecated 0.10.0 + * @codeCoverageIgnore */ public function getExactHeight() { - return $this->exactHeight; + return $this->isExactHeight(); } } diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index 5333a0b6..255da5b6 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -53,7 +53,7 @@ class TOC extends Tab */ public function setTabPos($value) { - $this->position = $value; + $this->setPosition($value); } /** @@ -73,7 +73,7 @@ class TOC extends Tab */ public function setTabLeader($value = self::TABLEADER_DOT) { - $this->leader = $value; + $this->setLeader($value); } /** diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index c4ec8b68..9995a2f2 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -224,7 +224,7 @@ class Table extends Border /** * Set border size inside horizontal * - * @param $value + * @param int $value */ public function setBorderInsideHSize($value = null) { @@ -234,7 +234,7 @@ class Table extends Border /** * Get border size inside horizontal * - * @return + * @return int */ public function getBorderInsideHSize() { @@ -244,7 +244,7 @@ class Table extends Border /** * Set border size inside vertical * - * @param $value + * @param int $value */ public function setBorderInsideVSize($value = null) { @@ -254,7 +254,7 @@ class Table extends Border /** * Get border size inside vertical * - * @return + * @return int */ public function getBorderInsideVSize() { @@ -264,7 +264,7 @@ class Table extends Border /** * Set border color inside horizontal * - * @param $value + * @param string $value */ public function setBorderInsideHColor($value = null) { @@ -274,7 +274,7 @@ class Table extends Border /** * Get border color inside horizontal * - * @return + * @return string */ public function getBorderInsideHColor() { @@ -284,7 +284,7 @@ class Table extends Border /** * Set border color inside vertical * - * @param $value + * @param string $value */ public function setBorderInsideVColor($value = null) { @@ -294,7 +294,7 @@ class Table extends Border /** * Get border color inside vertical * - * @return + * @return string */ public function getBorderInsideVColor() { diff --git a/src/PhpWord/TOC.php b/src/PhpWord/TOC.php deleted file mode 100644 index 577fe4ab..00000000 --- a/src/PhpWord/TOC.php +++ /dev/null @@ -1,84 +0,0 @@ -useDiskCaching; } @@ -131,7 +131,7 @@ abstract class AbstractWriter implements WriterInterface /** * Set use disk caching status * - * @param boolean $pValue + * @param bool $pValue * @param string $pDirectory * @return self */ @@ -356,4 +356,15 @@ abstract class AbstractWriter implements WriterInterface rmdir($dir); } + + /** + * Get use disk caching status + * + * @deprecated 0.10.0 + * @codeCoverageIgnore + */ + public function getUseDiskCaching() + { + return $this->isUseDiskCaching(); + } } diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index 73ae14c1..3d217f33 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -41,22 +41,22 @@ class Font extends AbstractStyle $css['color'] = '#' . $this->style->getColor(); } $css['background'] = $this->style->getFgColor(); - if ($this->style->getBold()) { + if ($this->style->isBold()) { $css['font-weight'] = 'bold'; } - if ($this->style->getItalic()) { + if ($this->style->isItalic()) { $css['font-style'] = 'italic'; } - if ($this->style->getSuperScript()) { + if ($this->style->isSuperScript()) { $css['vertical-align'] = 'super'; - } elseif ($this->style->getSubScript()) { + } elseif ($this->style->isSubScript()) { $css['vertical-align'] = 'sub'; } $css['text-decoration'] = ''; if ($this->style->getUnderline() != FontStyle::UNDERLINE_NONE) { $css['text-decoration'] .= 'underline '; } - if ($this->style->getStrikethrough()) { + if ($this->style->isStrikethrough()) { $css['text-decoration'] .= 'line-through '; } diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index 63ce7b68..b9f8de4d 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -25,12 +25,12 @@ class Text extends Element $paragraphStyle = $this->element->getParagraphStyle(); // @todo Commented for TextRun. Should really checkout this value - // $SfIsObject = ($fontStyle instanceof Font) ? true : false; - $SfIsObject = false; + // $fStyleIsObject = ($fontStyle instanceof Font) ? true : false; + $fStyleIsObject = false; - if ($SfIsObject) { + if ($fStyleIsObject) { // Don't never be the case, because I browse all sections for cleaning all styles not declared - throw new Exception('PhpWord : $SfIsObject wouldn\'t be an object'); + throw new Exception('PhpWord : $fStyleIsObject wouldn\'t be an object'); } else { if (!$this->withoutP) { $this->xmlWriter->startElement('text:p'); // text:p diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php index 822e8a90..bf174ee6 100644 --- a/src/PhpWord/Writer/ODText/Style/Font.php +++ b/src/PhpWord/Writer/ODText/Style/Font.php @@ -48,12 +48,12 @@ class Font extends AbstractStyle if ($this->style->getColor()) { $this->xmlWriter->writeAttribute('fo:color', '#' . $this->style->getColor()); } - if ($this->style->getItalic()) { + if ($this->style->isItalic()) { $this->xmlWriter->writeAttribute('fo:font-style', 'italic'); $this->xmlWriter->writeAttribute('style:font-style-asian', 'italic'); $this->xmlWriter->writeAttribute('style:font-style-complex', 'italic'); } - if ($this->style->getBold()) { + if ($this->style->isBold()) { $this->xmlWriter->writeAttribute('fo:font-weight', 'bold'); $this->xmlWriter->writeAttribute('style:font-weight-asian', 'bold'); } diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php index 2ee110e0..bbd36f65 100644 --- a/src/PhpWord/Writer/RTF/Element/Text.php +++ b/src/PhpWord/Writer/RTF/Element/Text.php @@ -73,10 +73,10 @@ class Text extends Element } else { $rtfText .= '\f0'; } - if ($fontStyle->getBold()) { + if ($fontStyle->isBold()) { $rtfText .= '\b'; } - if ($fontStyle->getItalic()) { + if ($fontStyle->isItalic()) { $rtfText .= '\i'; } if ($fontStyle->getSize()) { @@ -92,10 +92,10 @@ class Text extends Element $rtfText .= '\cf0'; $rtfText .= '\f0'; - if ($fontStyle->getBold()) { + if ($fontStyle->isBold()) { $rtfText .= '\b0'; } - if ($fontStyle->getItalic()) { + if ($fontStyle->isItalic()) { $rtfText .= '\i0'; } if ($fontStyle->getSize()) { diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index e944b7af..8da8a13b 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -23,7 +23,7 @@ class Image extends Element */ public function write() { - if ($this->element->getIsWatermark()) { + if ($this->element->isWatermark()) { $this->writeWatermark(); } else { $this->writeImage(); diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index c538561a..f8387960 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -84,25 +84,22 @@ class Table extends Element $row = $rows[$i]; $height = $row->getHeight(); $rowStyle = $row->getStyle(); - $tblHeader = $rowStyle->getTblHeader(); - $cantSplit = $rowStyle->getCantSplit(); - $exactHeight = $rowStyle->getExactHeight(); $this->xmlWriter->startElement('w:tr'); - if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) { + if (!is_null($height) || $rowStyle->isTblHeader() || $rowStyle->isCantSplit()) { $this->xmlWriter->startElement('w:trPr'); if (!is_null($height)) { $this->xmlWriter->startElement('w:trHeight'); $this->xmlWriter->writeAttribute('w:val', $height); - $this->xmlWriter->writeAttribute('w:hRule', ($exactHeight ? 'exact' : 'atLeast')); + $this->xmlWriter->writeAttribute('w:hRule', ($rowStyle->isExactHeight() ? 'exact' : 'atLeast')); $this->xmlWriter->endElement(); } - if ($tblHeader) { + if ($rowStyle->isTblHeader()) { $this->xmlWriter->startElement('w:tblHeader'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); } - if ($cantSplit) { + if ($rowStyle->isCantSplit()) { $this->xmlWriter->startElement('w:cantSplit'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index afa84caf..914c0407 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -63,7 +63,7 @@ abstract class AbstractPart { $useDiskCaching = false; if (!is_null($this->parentWriter)) { - if ($this->parentWriter->getUseDiskCaching()) { + if ($this->parentWriter->isUseDiskCaching()) { $useDiskCaching = true; } } diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php index 00e05c76..e89b8d79 100644 --- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php @@ -24,24 +24,24 @@ class ContentTypes extends AbstractPart */ public function writeContentTypes($contentTypes) { - $OpenXMLPrefix = 'application/vnd.openxmlformats-'; - $WordMLPrefix = $OpenXMLPrefix . 'officedocument.wordprocessingml.'; + $openXMLPrefix = 'application/vnd.openxmlformats-'; + $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.'; $overrides = array( - '/docProps/core.xml' => $OpenXMLPrefix . 'package.core-properties+xml', - '/docProps/app.xml' => $OpenXMLPrefix . 'officedocument.extended-properties+xml', - '/word/document.xml' => $WordMLPrefix . 'document.main+xml', - '/word/styles.xml' => $WordMLPrefix . 'styles+xml', - '/word/numbering.xml' => $WordMLPrefix . 'numbering+xml', - '/word/settings.xml' => $WordMLPrefix . 'settings+xml', - '/word/theme/theme1.xml' => $OpenXMLPrefix . 'officedocument.theme+xml', - '/word/webSettings.xml' => $WordMLPrefix . 'webSettings+xml', - '/word/fontTable.xml' => $WordMLPrefix . 'fontTable+xml', + '/docProps/core.xml' => $openXMLPrefix . 'package.core-properties+xml', + '/docProps/app.xml' => $openXMLPrefix . 'officedocument.extended-properties+xml', + '/word/document.xml' => $wordMLPrefix . 'document.main+xml', + '/word/styles.xml' => $wordMLPrefix . 'styles+xml', + '/word/numbering.xml' => $wordMLPrefix . 'numbering+xml', + '/word/settings.xml' => $wordMLPrefix . 'settings+xml', + '/word/theme/theme1.xml' => $openXMLPrefix . 'officedocument.theme+xml', + '/word/webSettings.xml' => $wordMLPrefix . 'webSettings+xml', + '/word/fontTable.xml' => $wordMLPrefix . 'fontTable+xml', ); $defaults = $contentTypes['default']; if (!empty($contentTypes['override'])) { foreach ($contentTypes['override'] as $key => $val) { - $overrides[$key] = $WordMLPrefix . $val . '+xml'; + $overrides[$key] = $wordMLPrefix . $val . '+xml'; } } diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php index 6ffc6a87..b6a46b5b 100644 --- a/src/PhpWord/Writer/Word2007/Style/Font.php +++ b/src/PhpWord/Writer/Word2007/Style/Font.php @@ -89,12 +89,12 @@ class Font extends AbstractStyle } // Bold - if ($this->style->getBold()) { + if ($this->style->isBold()) { $this->xmlWriter->writeElement('w:b', null); } // Italic - if ($this->style->getItalic()) { + if ($this->style->isItalic()) { $this->xmlWriter->writeElement('w:i', null); $this->xmlWriter->writeElement('w:iCs', null); } @@ -107,12 +107,12 @@ class Font extends AbstractStyle } // Strikethrough - if ($this->style->getStrikethrough()) { + if ($this->style->isStrikethrough()) { $this->xmlWriter->writeElement('w:strike', null); } // Double strikethrough - if ($this->style->getDoubleStrikethrough()) { + if ($this->style->isDoubleStrikethrough()) { $this->xmlWriter->writeElement('w:dstrike', null); } @@ -130,19 +130,19 @@ class Font extends AbstractStyle } // Superscript/subscript - if ($this->style->getSuperScript() || $this->style->getSubScript()) { + if ($this->style->isSuperScript() || $this->style->isSubScript()) { $this->xmlWriter->startElement('w:vertAlign'); - $this->xmlWriter->writeAttribute('w:val', $this->style->getSuperScript() ? 'superscript' : 'subscript'); + $this->xmlWriter->writeAttribute('w:val', $this->style->isSuperScript() ? 'superscript' : 'subscript'); $this->xmlWriter->endElement(); } // Small caps - if ($this->style->getSmallCaps()) { + if ($this->style->isSmallCaps()) { $this->xmlWriter->writeElement('w:smallCaps', null); } // All caps - if ($this->style->getAllCaps()) { + if ($this->style->isAllCaps()) { $this->xmlWriter->writeElement('w:caps', null); } diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php index b92e1714..d2978ff8 100644 --- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php +++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php @@ -64,11 +64,6 @@ class Paragraph extends AbstractStyle return; } - $widowControl = $this->style->getWidowControl(); - $keepNext = $this->style->getKeepNext(); - $keepLines = $this->style->getKeepLines(); - $pageBreakBefore = $this->style->getPageBreakBefore(); - if (!$this->withoutPPR) { $this->xmlWriter->startElement('w:pPr'); } @@ -93,22 +88,22 @@ class Paragraph extends AbstractStyle } // Pagination - if (!$widowControl) { + if (!$this->style->hasWidowControl()) { $this->xmlWriter->startElement('w:widowControl'); $this->xmlWriter->writeAttribute('w:val', '0'); $this->xmlWriter->endElement(); } - if ($keepNext) { + if ($this->style->isKeepNext()) { $this->xmlWriter->startElement('w:keepNext'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); } - if ($keepLines) { + if ($this->style->isKeepLines()) { $this->xmlWriter->startElement('w:keepLines'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); } - if ($pageBreakBefore) { + if ($this->style->hasPageBreakBefore()) { $this->xmlWriter->startElement('w:pageBreakBefore'); $this->xmlWriter->writeAttribute('w:val', '1'); $this->xmlWriter->endElement(); diff --git a/tests/PhpWord/Tests/Element/ImageTest.php b/tests/PhpWord/Tests/Element/ImageTest.php index eb482398..4d927b42 100644 --- a/tests/PhpWord/Tests/Element/ImageTest.php +++ b/tests/PhpWord/Tests/Element/ImageTest.php @@ -29,7 +29,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Image', $oImage); $this->assertEquals($oImage->getSource(), $src); $this->assertEquals($oImage->getMediaId(), md5($src)); - $this->assertEquals($oImage->getIsWatermark(), false); + $this->assertEquals($oImage->isWatermark(), false); $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oImage->getStyle()); } @@ -72,7 +72,7 @@ class ImageTest extends \PHPUnit_Framework_TestCase $this->assertEquals($image->getImageExtension(), $extension); $this->assertEquals($image->getImageCreateFunction(), $createFunction); $this->assertEquals($image->getImageFunction(), $imageFunction); - $this->assertFalse($image->getIsMemImage()); + $this->assertFalse($image->isMemImage()); } } diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index 64a09994..ced861cb 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -23,9 +23,9 @@ class SettingsTest extends \PHPUnit_Framework_TestCase */ public function testSetGetCompatibility() { - $this->assertTrue(Settings::getCompatibility()); + $this->assertTrue(Settings::hasCompatibility()); $this->assertTrue(Settings::setCompatibility(false)); - $this->assertFalse(Settings::getCompatibility()); + $this->assertFalse(Settings::hasCompatibility()); $this->assertFalse(Settings::setCompatibility('Non boolean')); } diff --git a/tests/PhpWord/Tests/Shared/DrawingTest.php b/tests/PhpWord/Tests/Shared/DrawingTest.php index 713cebcd..519e0187 100644 --- a/tests/PhpWord/Tests/Shared/DrawingTest.php +++ b/tests/PhpWord/Tests/Shared/DrawingTest.php @@ -32,7 +32,7 @@ class DrawingTest extends \PHPUnit_Framework_TestCase $result = Drawing::pixelsToEMU($value); $this->assertEquals(round($value * 9525), $result); - $result = Drawing::EMUToPixels($value); + $result = Drawing::emuToPixels($value); $this->assertEquals(round($value / 9525), $result); $result = Drawing::pixelsToPoints($value); diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index b02c3f9f..915a5649 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -129,7 +129,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase { $object = new ODText(); $object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR); - $this->assertTrue($object->getUseDiskCaching()); + $this->assertTrue($object->isUseDiskCaching()); $this->assertEquals(PHPWORD_TESTS_BASE_DIR, $object->getDiskCachingDirectory()); } diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index 74f3b1fd..52f93927 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -177,7 +177,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase $writer = new Word2007($phpWord); $writer->save('php://output'); - $this->assertTrue($object->getUseDiskCaching()); + $this->assertTrue($object->isUseDiskCaching()); } /**