From f1108c48e60bdd3f509683a618481e03c9866258 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 8 Apr 2014 00:23:49 +0700 Subject: [PATCH] Add Abstract- prefix and -Interface suffix for corresponding classes --- CHANGELOG.md | 16 +- src/PhpWord/Element/AbstractElement.php | 225 ++++++++++++------ src/PhpWord/Element/Cell.php | 3 +- src/PhpWord/Element/CheckBox.php | 2 +- src/PhpWord/Element/Element.php | 106 --------- src/PhpWord/Element/Footer.php | 4 +- src/PhpWord/Element/Footnote.php | 3 +- src/PhpWord/Element/Header.php | 4 +- src/PhpWord/Element/Image.php | 5 +- src/PhpWord/Element/Link.php | 2 +- src/PhpWord/Element/ListItem.php | 2 +- src/PhpWord/Element/Object.php | 2 +- src/PhpWord/Element/PageBreak.php | 2 +- src/PhpWord/Element/PreserveText.php | 2 +- src/PhpWord/Element/Row.php | 2 +- src/PhpWord/Element/Section.php | 18 +- src/PhpWord/Element/Table.php | 2 +- src/PhpWord/Element/Text.php | 2 +- src/PhpWord/Element/TextBreak.php | 2 +- src/PhpWord/Element/TextRun.php | 3 +- src/PhpWord/Element/Title.php | 2 +- src/PhpWord/IOFactory.php | 8 +- src/PhpWord/PhpWord.php | 4 +- .../Reader/{Reader.php => AbstractReader.php} | 6 +- .../{IReader.php => ReaderInterface.php} | 4 +- src/PhpWord/Reader/Word2007.php | 4 +- src/PhpWord/Style/Section.php | 4 +- .../Writer/{Writer.php => AbstractWriter.php} | 2 +- src/PhpWord/Writer/ODText.php | 2 +- ...{WriterPart.php => AbstractWriterPart.php} | 2 +- src/PhpWord/Writer/ODText/Content.php | 2 +- src/PhpWord/Writer/ODText/Manifest.php | 2 +- src/PhpWord/Writer/ODText/Meta.php | 2 +- src/PhpWord/Writer/ODText/Mimetype.php | 2 +- src/PhpWord/Writer/ODText/Styles.php | 2 +- src/PhpWord/Writer/RTF.php | 2 +- src/PhpWord/Writer/Word2007.php | 4 +- ...{WriterPart.php => AbstractWriterPart.php} | 14 +- src/PhpWord/Writer/Word2007/Base.php | 8 +- src/PhpWord/Writer/Word2007/ContentTypes.php | 2 +- src/PhpWord/Writer/Word2007/DocProps.php | 2 +- src/PhpWord/Writer/Word2007/Document.php | 2 +- src/PhpWord/Writer/Word2007/Footer.php | 2 +- src/PhpWord/Writer/Word2007/Header.php | 2 +- src/PhpWord/Writer/Word2007/Rels.php | 2 +- .../{IWriter.php => WriterInterface.php} | 2 +- tests/PhpWord/Tests/Element/FooterTest.php | 8 +- tests/PhpWord/Tests/Element/HeaderTest.php | 8 +- tests/PhpWord/Tests/Element/PageBreakTest.php | 1 - tests/PhpWord/Tests/Element/SectionTest.php | 10 +- tests/PhpWord/Tests/MediaTest.php | 2 +- tests/PhpWord/Tests/PhpWordTest.php | 2 +- tests/PhpWord/Tests/Style/SectionTest.php | 36 +-- ...artTest.php => AbstractWriterPartTest.php} | 12 +- ...artTest.php => AbstractWriterPartTest.php} | 14 +- .../Tests/Writer/Word2007/FooterTest.php | 2 +- .../Tests/Writer/Word2007/HeaderTest.php | 2 +- 57 files changed, 284 insertions(+), 310 deletions(-) delete mode 100644 src/PhpWord/Element/Element.php rename src/PhpWord/Reader/{Reader.php => AbstractReader.php} (91%) rename src/PhpWord/Reader/{IReader.php => ReaderInterface.php} (86%) rename src/PhpWord/Writer/{Writer.php => AbstractWriter.php} (98%) rename src/PhpWord/Writer/ODText/{WriterPart.php => AbstractWriterPart.php} (73%) rename src/PhpWord/Writer/Word2007/{WriterPart.php => AbstractWriterPart.php} (80%) rename src/PhpWord/Writer/{IWriter.php => WriterInterface.php} (93%) rename tests/PhpWord/Tests/Writer/ODText/{WriterPartTest.php => AbstractWriterPartTest.php} (69%) rename tests/PhpWord/Tests/Writer/Word2007/{WriterPartTest.php => AbstractWriterPartTest.php} (66%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c3ed441..1e159009 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,8 +39,8 @@ This is the changelog between releases of PHPWord. Releases are listed in revers - `createHeader` replaced by `addHeader` - `createFooter` replaced by `addFooter` - `createSection` replaced by `addSection` -- `Element\Footnote::getReferenceId` replaced by `Container\Container::getRelationId` -- `Element\Footnote::setReferenceId` replaced by `Container\Container::setRelationId` +- `Element\Footnote::getReferenceId` replaced by `Element\AbstractElement::getRelationId` +- `Element\Footnote::setReferenceId` replaced by `Element\AbstractElement::setRelationId` - `Footnote::addFootnoteLinkElement` replaced by `Media::addElement` - `Footnote::getFootnoteLinkElements` replaced by `Media::getElements` - All current methods on `Media` @@ -48,14 +48,14 @@ This is the changelog between releases of PHPWord. Releases are listed in revers ### Miscellaneous - Documentation: Simplify page level docblock - @ivanlanin GH-179 -- Writer: Refactor writer classes and make a new Writer abstract class - @ivanlanin GH-160 -- Reader: Rename AbstractReader > Reader - @ivanlanin -- General: Refactor folders: Element, Container, and Exception - @ivanlanin GH-187 +- Writer: Refactor writer classes and make a new AbstractWriter abstract class - @ivanlanin GH-160 +- General: Refactor folders: Element and Exception - @ivanlanin GH-187 - General: Remove legacy HashTable and ZipStreamWrapper and all related properties/methods - @ivanlanin GH-187 -- Container: Create new Container abstract class - @ivanlanin GH-187 -- Element: Create new Element abstract class - @ivanlanin GH-187 +- Element: Create new AbstractElement abstract class - @ivanlanin GH-187 - Media: Refactor media class to use one method for all docPart (section, header, footer, footnote) - @ivanlanin GH-187 -- General: Remove underscore prefix from all private properties name +- General: Remove underscore prefix from all private properties name - @ivanlanin GH-187 +- General: Move Section Settings to Style\Section - @ivanlanin GH-187 +- General: Give `Abstract` prefix and `Interface` suffix for all abstract classes and interfaces as per [PHP-FIG recommendation](https://github.com/php-fig/fig-standards/blob/master/bylaws/002-psr-naming-conventions.md) - @ivanlanin GH-187 ## 0.9.1 - 27 Mar 2014 diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php index 2584a1f7..eabb1963 100644 --- a/src/PhpWord/Element/AbstractElement.php +++ b/src/PhpWord/Element/AbstractElement.php @@ -7,7 +7,7 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Container; +namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Exception\InvalidImageException; use PhpOffice\PhpWord\Exception\InvalidObjectException; @@ -35,7 +35,7 @@ use PhpOffice\PhpWord\Element\CheckBox; * * @since 0.9.2 */ -abstract class Container extends Element +abstract class AbstractElement { /** * Container type section|header|footer|cell|textrun|footnote @@ -51,6 +51,28 @@ abstract class Container extends Element */ protected $sectionId; + /** + * Document part type: section|header|footer + * + * Used by textrun and cell container to determine where the element is + * located because it will affect the availability of other element, + * e.g. footnote will not be available when $docPart is header or footer. + * + * @var string + */ + private $docPart = 'section'; + + /** + * Document part Id + * + * For header and footer, this will be = ($sectionId - 1) * 3 + $index + * because the max number of header/footer in every page is 3, i.e. + * AUTO, FIRST, and EVEN (AUTO = ODD) + * + * @var integer + */ + private $docPartId = 1; + /** * Elements collection * @@ -340,6 +362,38 @@ abstract class Container extends Element return $this->sectionId; } + /** + * Set doc part + * + * @param string $docPart + * @param integer $docPartId + */ + public function setDocPart($docPart, $docPartId = 1) + { + $this->docPart = $docPart; + $this->docPartId = $docPartId; + } + + /** + * Get doc part + * + * @return string + */ + public function getDocPart() + { + return $this->docPart; + } + + /** + * Get doc part Id + * + * @return integer + */ + public function getDocPartId() + { + return $this->docPartId; + } + /** * Get all elements * @@ -372,6 +426,106 @@ abstract class Container extends Element $this->relationId = $rId; } + /** + * Check if element is located in section doc part (as opposed to header/footer) + * + * @return boolean + */ + public function isInSection() + { + return ($this->docPart == 'section'); + } + + /** + * Set style value + * + * @param mixed $styleObject Style object + * @param mixed $styleValue Style value + * @param boolean $returnObject Always return object + */ + protected function setStyle($styleObject, $styleValue = null, $returnObject = false) + { + if (!is_null($styleValue) && is_array($styleValue)) { + foreach ($styleValue as $key => $value) { + if (substr($key, 0, 1) == '_') { + $key = substr($key, 1); + } + $styleObject->setStyleValue($key, $value); + } + $style = $styleObject; + } else { + $style = $returnObject ? $styleObject : $styleValue; + } + + return $style; + } + + /** + * Check if a method is allowed for the current container + * + * @param string $method + * @return boolean + */ + private function checkValidity($method) + { + // Valid containers for each element + $allContainers = array('section', 'header', 'footer', 'cell', 'textrun', 'footnote'); + $validContainers = array( + 'text' => $allContainers, + 'link' => $allContainers, + 'textbreak' => $allContainers, + 'image' => $allContainers, + 'object' => $allContainers, + 'textrun' => array('section', 'header', 'footer', 'cell'), + 'listitem' => array('section', 'header', 'footer', 'cell'), + 'checkbox' => array('section', 'header', 'footer', 'cell'), + 'table' => array('section', 'header', 'footer'), + 'footnote' => array('section', 'textrun', 'cell'), + 'preservetext' => array('header', 'footer', 'cell'), + 'relationid' => array('header', 'footer', 'footnote'), + 'title' => array('section'), + ); + // Special condition, e.g. preservetext can only exists in cell when + // the cell is located in header or footer + $validContainerInContainers = array( + 'preservetext' => array(array('cell'), array('header', 'footer')), + 'footnote' => array(array('cell', 'textrun'), array('section')), + ); + + // Check if a method is valid for current container + if (array_key_exists($method, $validContainers)) { + if (!in_array($this->container, $validContainers[$method])) { + throw new \BadMethodCallException(); + } + } + // Check if a method is valid for current container, located in other container + if (array_key_exists($method, $validContainerInContainers)) { + $rules = $validContainerInContainers[$method]; + $containers = $rules[0]; + $allowedDocParts = $rules[1]; + foreach ($containers as $container) { + if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) { + throw new \BadMethodCallException(); + } + } + } + + return true; + } + + /** + * Return element location in document: section, headerx, or footerx + */ + private function checkElementDocPart() + { + $isCellTextrun = in_array($this->container, array('cell', 'textrun')); + $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; + $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; + $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); + + return $inHeaderFooter ? $docPart . $docPartId : $docPart; + } + /** * Add memory image element * @@ -408,71 +562,4 @@ abstract class Container extends Element { return $this->addFootnote($paragraphStyle); } - - /** - * Check if a method is allowed for the current container - * - * @param string $method - * @return boolean - */ - private function checkValidity($method) - { - // Empty array means the element can be accepted by all containers - $validContainers = array( - 'text' => array(), - 'link' => array(), - 'textbreak' => array(), - 'image' => array(), - 'object' => array(), - 'textrun' => array('section', 'header', 'footer', 'cell'), - 'listitem' => array('section', 'header', 'footer', 'cell'), - 'checkbox' => array('section', 'header', 'footer', 'cell'), - 'table' => array('section', 'header', 'footer'), - 'footnote' => array('section', 'textrun', 'cell'), - 'preservetext' => array('header', 'footer', 'cell'), - 'relationid' => array('header', 'footer', 'footnote'), - 'title' => array('section'), - ); - // Special condition, e.g. preservetext can only exists in cell when - // the cell is located in header or footer - $validContainerInContainers = array( - 'preservetext' => array(array('cell'), array('header', 'footer')), - 'footnote' => array(array('cell', 'textrun'), array('section')), - ); - - // Check if a method is valid for current container - if (array_key_exists($method, $validContainers)) { - if (!empty($validContainers[$method])) { - if (!in_array($this->container, $validContainers[$method])) { - throw new \BadMethodCallException(); - } - } - } - // Check if a method is valid for current container, located in other container - if (array_key_exists($method, $validContainerInContainers)) { - $rules = $validContainerInContainers[$method]; - $containers = $rules[0]; - $allowedDocParts = $rules[1]; - foreach ($containers as $container) { - if ($this->container == $container && !in_array($this->getDocPart(), $allowedDocParts)) { - throw new \BadMethodCallException(); - } - } - } - - return true; - } - - /** - * Return element location in document: section, headerx, or footerx - */ - private function checkElementDocPart() - { - $isCellTextrun = in_array($this->container, array('cell', 'textrun')); - $docPart = $isCellTextrun ? $this->getDocPart() : $this->container; - $docPartId = $isCellTextrun ? $this->getDocPartId() : $this->sectionId; - $inHeaderFooter = ($docPart == 'header' || $docPart == 'footer'); - - return $inHeaderFooter ? $docPart . $docPartId : $docPart; - } } diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php index 5e035fb7..2f92bce1 100755 --- a/src/PhpWord/Element/Cell.php +++ b/src/PhpWord/Element/Cell.php @@ -9,13 +9,12 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Container\Container; use PhpOffice\PhpWord\Style\Cell as CellStyle; /** * Table cell element */ -class Cell extends Container +class Cell extends AbstractElement { /** * Cell width diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php index 187bd132..31f067d7 100644 --- a/src/PhpWord/Element/CheckBox.php +++ b/src/PhpWord/Element/CheckBox.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** * Check box element */ -class CheckBox extends Element +class CheckBox extends AbstractElement { /** * Name content diff --git a/src/PhpWord/Element/Element.php b/src/PhpWord/Element/Element.php deleted file mode 100644 index 6cebd0d5..00000000 --- a/src/PhpWord/Element/Element.php +++ /dev/null @@ -1,106 +0,0 @@ - $value) { - if (substr($key, 0, 1) == '_') { - $key = substr($key, 1); - } - $styleObject->setStyleValue($key, $value); - } - $style = $styleObject; - } else { - $style = $returnObject ? $styleObject : $styleValue; - } - - return $style; - } - - /** - * Set doc part - * - * @param string $docPart - * @param integer $docPartId - */ - public function setDocPart($docPart, $docPartId = 1) - { - $this->docPart = $docPart; - $this->docPartId = $docPartId; - } - - /** - * Get doc part - * - * @return string - */ - public function getDocPart() - { - return $this->docPart; - } - - /** - * Get doc part Id - * - * @return integer - */ - public function getDocPartId() - { - return $this->docPartId; - } - - /** - * Check if element is located in section doc part (as opposed to header/footer) - * - * @return boolean - */ - public function isInSection() - { - return ($this->docPart == 'section'); - } -} diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php index 47287c8b..6d441126 100755 --- a/src/PhpWord/Element/Footer.php +++ b/src/PhpWord/Element/Footer.php @@ -7,12 +7,12 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Container; +namespace PhpOffice\PhpWord\Element; /** * Footer element */ -class Footer extends Container +class Footer extends AbstractElement { const AUTO = 'default'; // default and odd pages const FIRST = 'first'; diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index ff0c9960..e79e9c79 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -9,13 +9,12 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Container\Container; use PhpOffice\PhpWord\Style\Paragraph; /** * Footnote element */ -class Footnote extends Container +class Footnote extends AbstractElement { /** * Paragraph style diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php index 2920e3cf..c14ed0e7 100755 --- a/src/PhpWord/Element/Header.php +++ b/src/PhpWord/Element/Header.php @@ -7,14 +7,14 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Container; +namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Element\Image; /** * Header element */ -class Header extends Container +class Header extends AbstractElement { /** * Header types constants diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index fec8791c..bf29220b 100755 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -16,7 +16,7 @@ use PhpOffice\PhpWord\Style\Image as ImageStyle; /** * Image element */ -class Image extends Element +class Image extends AbstractElement { /** * Image source @@ -138,9 +138,6 @@ class Image extends Element $this->source = $source; $this->isWatermark = $isWatermark; $this->style = $this->setStyle(new ImageStyle(), $style, true); - if (isset($style['wrappingStyle'])) { - $this->style->setWrappingStyle($style['wrappingStyle']); - } if ($this->style->getWidth() == null && $this->style->getHeight() == null) { $this->style->setWidth($imgData[0]); $this->style->setHeight($imgData[1]); diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index ee1af203..96c66339 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** * Link element */ -class Link extends Element +class Link extends AbstractElement { /** * Link source diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php index 6cf5d1d6..64ac149d 100644 --- a/src/PhpWord/Element/ListItem.php +++ b/src/PhpWord/Element/ListItem.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; /** * List item element */ -class ListItem extends Element +class ListItem extends AbstractElement { /** * ListItem Style diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index 5716b7e6..f6b4161b 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\Image as ImageStyle; /** * Object element */ -class Object extends Element +class Object extends AbstractElement { /** * Ole-Object Src diff --git a/src/PhpWord/Element/PageBreak.php b/src/PhpWord/Element/PageBreak.php index c297681d..d2f85f20 100644 --- a/src/PhpWord/Element/PageBreak.php +++ b/src/PhpWord/Element/PageBreak.php @@ -12,7 +12,7 @@ namespace PhpOffice\PhpWord\Element; /** * Page break element */ -class PageBreak extends Element +class PageBreak extends AbstractElement { /** * Create new page break diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index 0fe77d9a..76e860fe 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** * Preserve text/field element */ -class PreserveText extends Element +class PreserveText extends AbstractElement { /** * Text content diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php index 53990850..c20b018b 100644 --- a/src/PhpWord/Element/Row.php +++ b/src/PhpWord/Element/Row.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\Style\Row as RowStyle; /** * Table row element */ -class Row extends Element +class Row extends AbstractElement { /** * Row height diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index dae4f26c..2be0794a 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -7,24 +7,24 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Container; +namespace PhpOffice\PhpWord\Element; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\TOC; -use PhpOffice\PhpWord\Container\Footer; -use PhpOffice\PhpWord\Container\Header; -use PhpOffice\PhpWord\Container\Settings; +use PhpOffice\PhpWord\Element\Footer; +use PhpOffice\PhpWord\Element\Header; use PhpOffice\PhpWord\Element\PageBreak; +use PhpOffice\PhpWord\Style\Section as SectionSettings; /** * Section */ -class Section extends Container +class Section extends AbstractElement { /** * Section settings * - * @var Settings + * @var SectionSettings */ private $settings; @@ -53,7 +53,7 @@ class Section extends Container $this->container = 'section'; $this->sectionId = $sectionCount; $this->setDocPart($this->container, $this->sectionId); - $this->settings = new Settings(); + $this->settings = new SectionSettings(); $this->setSettings($settings); } @@ -77,7 +77,7 @@ class Section extends Container /** * Get Section Settings * - * @return Settings + * @return SectionSettings */ public function getSettings() { @@ -181,7 +181,7 @@ class Section extends Container private function addHeaderFooter($type = Header::AUTO, $header = true) { $collectionArray = $header ? 'headers' : 'footers'; - $containerClass = 'PhpOffice\\PhpWord\\Container\\'; + $containerClass = 'PhpOffice\\PhpWord\\Element\\'; $containerClass .= ($header ? 'Header' : 'Footer'); $collection = &$this->$collectionArray; diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php index 5808a065..0c8d494d 100644 --- a/src/PhpWord/Element/Table.php +++ b/src/PhpWord/Element/Table.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Table as TableStyle; /** * Table element */ -class Table extends Element +class Table extends AbstractElement { /** * Table style diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php index 620095b8..bb1d5aac 100644 --- a/src/PhpWord/Element/Text.php +++ b/src/PhpWord/Element/Text.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** * Text element */ -class Text extends Element +class Text extends AbstractElement { /** * Text content diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php index adf144ba..aa3d5cca 100755 --- a/src/PhpWord/Element/TextBreak.php +++ b/src/PhpWord/Element/TextBreak.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Style\Paragraph; /** * Text break element */ -class TextBreak extends Element +class TextBreak extends AbstractElement { /** * Paragraph style diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php index 6be08fc4..f7286d8f 100755 --- a/src/PhpWord/Element/TextRun.php +++ b/src/PhpWord/Element/TextRun.php @@ -9,13 +9,12 @@ namespace PhpOffice\PhpWord\Element; -use PhpOffice\PhpWord\Container\Container; use PhpOffice\PhpWord\Style\Paragraph; /** * Textrun/paragraph element */ -class TextRun extends Container +class TextRun extends AbstractElement { /** * Paragraph style diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php index c8c29a35..5ed1bfbc 100644 --- a/src/PhpWord/Element/Title.php +++ b/src/PhpWord/Element/Title.php @@ -12,7 +12,7 @@ namespace PhpOffice\PhpWord\Element; /** * Title element */ -class Title extends Element +class Title extends AbstractElement { /** * Title Text content diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index eeafb057..7b32ef44 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -21,12 +21,12 @@ abstract class IOFactory * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $name - * @return \PhpOffice\PhpWord\Writer\IWriter + * @return \PhpOffice\PhpWord\Writer\WriterInterface * @throws Exception */ public static function createWriter(PhpWord $phpWord, $name = 'Word2007') { - if ($name !== 'IWriter' && $name !== 'ODText' && $name !== 'RTF' && $name !== 'Word2007') { + if ($name !== 'WriterInterface' && $name !== 'ODText' && $name !== 'RTF' && $name !== 'Word2007') { throw new Exception("\"{$name}\" is not a valid writer."); } @@ -38,12 +38,12 @@ abstract class IOFactory * Create new reader * * @param string $name - * @return \PhpOffice\PhpWord\Reader\IReader + * @return \PhpOffice\PhpWord\Reader\ReaderInterface * @throws Exception */ public static function createReader($name = 'Word2007') { - if ($name !== 'IReader' && $name !== 'Word2007') { + if ($name !== 'ReaderInterface' && $name !== 'Word2007') { throw new Exception("\"{$name}\" is not a valid reader."); } diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 447706af..63d26a09 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\DocumentProperties; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Container\Section; +use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Template; @@ -217,7 +217,7 @@ class PhpWord /** * Get all sections * - * @return \PhpOffice\PhpWord\Container\Section[] + * @return \PhpOffice\PhpWord\Element\Section[] */ public function getSections() { diff --git a/src/PhpWord/Reader/Reader.php b/src/PhpWord/Reader/AbstractReader.php similarity index 91% rename from src/PhpWord/Reader/Reader.php rename to src/PhpWord/Reader/AbstractReader.php index e93b4636..10c864f3 100644 --- a/src/PhpWord/Reader/Reader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -16,7 +16,7 @@ use PhpOffice\PhpWord\Exception\Exception; * * @codeCoverageIgnore Abstract class */ -abstract class Reader implements IReader +abstract class AbstractReader implements ReaderInterface { /** * Read data only? @@ -47,7 +47,7 @@ abstract class Reader implements IReader * Set read data only * * @param bool $pValue - * @return \PhpOffice\PhpWord\Reader\IReader + * @return \PhpOffice\PhpWord\Reader\ReaderInterface */ public function setReadDataOnly($pValue = true) { @@ -77,7 +77,7 @@ abstract class Reader implements IReader } /** - * Can the current IReader read the file? + * Can the current ReaderInterface read the file? * * @param string $pFilename * @return bool diff --git a/src/PhpWord/Reader/IReader.php b/src/PhpWord/Reader/ReaderInterface.php similarity index 86% rename from src/PhpWord/Reader/IReader.php rename to src/PhpWord/Reader/ReaderInterface.php index a4bea94e..2829d4ab 100644 --- a/src/PhpWord/Reader/IReader.php +++ b/src/PhpWord/Reader/ReaderInterface.php @@ -12,10 +12,10 @@ namespace PhpOffice\PhpWord\Reader; /** * Reader interface */ -interface IReader +interface ReaderInterface { /** - * Can the current IReader read the file? + * Can the current ReaderInterface read the file? * * @param string $pFilename * @return boolean diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 2cdb7f9a..3d26bb63 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -17,10 +17,10 @@ use PhpOffice\PhpWord\Exception\Exception; /** * Reader for Word2007 */ -class Word2007 extends Reader implements IReader +class Word2007 extends AbstractReader implements ReaderInterface { /** - * Can the current IReader read the file? + * Can the current ReaderInterface read the file? * * @param string $pFilename * @return bool diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php index 762d45c3..52352434 100644 --- a/src/PhpWord/Style/Section.php +++ b/src/PhpWord/Style/Section.php @@ -7,12 +7,12 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Container; +namespace PhpOffice\PhpWord\Style; /** * Section settings */ -class Settings +class Section { /** * Default Page Size Width diff --git a/src/PhpWord/Writer/Writer.php b/src/PhpWord/Writer/AbstractWriter.php similarity index 98% rename from src/PhpWord/Writer/Writer.php rename to src/PhpWord/Writer/AbstractWriter.php index e53d215a..b4f4b765 100644 --- a/src/PhpWord/Writer/Writer.php +++ b/src/PhpWord/Writer/AbstractWriter.php @@ -17,7 +17,7 @@ use PhpOffice\PhpWord\PhpWord; * * @since 0.9.2 */ -abstract class Writer implements IWriter +abstract class AbstractWriter implements WriterInterface { /** * PHPWord object diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index 10e90dd3..7e1da98c 100755 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -21,7 +21,7 @@ use PhpOffice\PhpWord\Writer\ODText\Styles; /** * ODText writer */ -class ODText extends Writer implements IWriter +class ODText extends AbstractWriter implements WriterInterface { /** * Create new ODText writer diff --git a/src/PhpWord/Writer/ODText/WriterPart.php b/src/PhpWord/Writer/ODText/AbstractWriterPart.php similarity index 73% rename from src/PhpWord/Writer/ODText/WriterPart.php rename to src/PhpWord/Writer/ODText/AbstractWriterPart.php index a6fa93cb..1a5831e0 100644 --- a/src/PhpWord/Writer/ODText/WriterPart.php +++ b/src/PhpWord/Writer/ODText/AbstractWriterPart.php @@ -12,6 +12,6 @@ namespace PhpOffice\PhpWord\Writer\ODText; /** * ODText writer part abstract */ -abstract class WriterPart extends \PhpOffice\PhpWord\Writer\Word2007\WriterPart +abstract class AbstractWriterPart extends \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart { } diff --git a/src/PhpWord/Writer/ODText/Content.php b/src/PhpWord/Writer/ODText/Content.php index 7fc0d2df..b902ffb3 100644 --- a/src/PhpWord/Writer/ODText/Content.php +++ b/src/PhpWord/Writer/ODText/Content.php @@ -29,7 +29,7 @@ use PhpOffice\PhpWord\TOC; /** * ODText content part writer */ -class Content extends WriterPart +class Content extends AbstractWriterPart { /** * Write content file to XML format diff --git a/src/PhpWord/Writer/ODText/Manifest.php b/src/PhpWord/Writer/ODText/Manifest.php index ecda1918..e94a1fd1 100755 --- a/src/PhpWord/Writer/ODText/Manifest.php +++ b/src/PhpWord/Writer/ODText/Manifest.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\PhpWord; /** * ODText manifest part writer */ -class Manifest extends WriterPart +class Manifest extends AbstractWriterPart { /** * Write Manifest file to XML format diff --git a/src/PhpWord/Writer/ODText/Meta.php b/src/PhpWord/Writer/ODText/Meta.php index fc5314e9..0df77827 100644 --- a/src/PhpWord/Writer/ODText/Meta.php +++ b/src/PhpWord/Writer/ODText/Meta.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\PhpWord; /** * ODText meta part writer */ -class Meta extends WriterPart +class Meta extends AbstractWriterPart { /** * Write Meta file to XML format diff --git a/src/PhpWord/Writer/ODText/Mimetype.php b/src/PhpWord/Writer/ODText/Mimetype.php index 1e713f2c..b8bc6539 100644 --- a/src/PhpWord/Writer/ODText/Mimetype.php +++ b/src/PhpWord/Writer/ODText/Mimetype.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\PhpWord; /** * ODText mimetype part writer */ -class Mimetype extends WriterPart +class Mimetype extends AbstractWriterPart { /** * Write Mimetype to Text format diff --git a/src/PhpWord/Writer/ODText/Styles.php b/src/PhpWord/Writer/ODText/Styles.php index 8839f568..306ee5fc 100644 --- a/src/PhpWord/Writer/ODText/Styles.php +++ b/src/PhpWord/Writer/ODText/Styles.php @@ -18,7 +18,7 @@ use PhpOffice\PhpWord\Style\Table; /** * ODText styloes part writer */ -class Styles extends WriterPart +class Styles extends AbstractWriterPart { /** * Write Styles file to XML format diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 8698365f..2505a76d 100755 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -29,7 +29,7 @@ use PhpOffice\PhpWord\TOC; /** * RTF writer */ -class RTF extends Writer implements IWriter +class RTF extends AbstractWriter implements WriterInterface { /** * Color register diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 8fe90339..b426d570 100755 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -26,7 +26,7 @@ use PhpOffice\PhpWord\Writer\Word2007\Styles; /** * Word2007 writer */ -class Word2007 extends Writer implements IWriter +class Word2007 extends AbstractWriter implements WriterInterface { /** * Content types values @@ -229,7 +229,7 @@ class Word2007 extends Writer implements IWriter /** * Add header/footer content * - * @param \PhpOffice\PhpWord\Container\Section $section + * @param \PhpOffice\PhpWord\Element\Section $section * @param mixed $objZip * @param string $elmType * @param integer $rID diff --git a/src/PhpWord/Writer/Word2007/WriterPart.php b/src/PhpWord/Writer/Word2007/AbstractWriterPart.php similarity index 80% rename from src/PhpWord/Writer/Word2007/WriterPart.php rename to src/PhpWord/Writer/Word2007/AbstractWriterPart.php index a61662e9..b58797db 100755 --- a/src/PhpWord/Writer/Word2007/WriterPart.php +++ b/src/PhpWord/Writer/Word2007/AbstractWriterPart.php @@ -10,27 +10,27 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Writer\IWriter; +use PhpOffice\PhpWord\Writer\WriterInterface; use PhpOffice\PhpWord\Shared\XMLWriter; /** * Word2007 writer part abstract class */ -abstract class WriterPart +abstract class AbstractWriterPart { /** * Parent writer * - * @var IWriter + * @var WriterInterface */ protected $parentWriter; /** * Set parent writer * - * @param IWriter $pWriter + * @param WriterInterface $pWriter */ - public function setParentWriter(IWriter $pWriter = null) + public function setParentWriter(WriterInterface $pWriter = null) { $this->parentWriter = $pWriter; } @@ -38,7 +38,7 @@ abstract class WriterPart /** * Get parent writer * - * @return IWriter + * @return WriterInterface * @throws Exception */ public function getParentWriter() @@ -46,7 +46,7 @@ abstract class WriterPart if (!is_null($this->parentWriter)) { return $this->parentWriter; } else { - throw new Exception("No parent IWriter assigned."); + throw new Exception("No parent WriterInterface assigned."); } } diff --git a/src/PhpWord/Writer/Word2007/Base.php b/src/PhpWord/Writer/Word2007/Base.php index 762bc7ea..a5f9a5e0 100644 --- a/src/PhpWord/Writer/Word2007/Base.php +++ b/src/PhpWord/Writer/Word2007/Base.php @@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\PhpWord; -use PhpOffice\PhpWord\Container\Container; +use PhpOffice\PhpWord\Element\AbstractElement; use PhpOffice\PhpWord\Element\Text; use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\Link; @@ -37,7 +37,7 @@ use PhpOffice\PhpWord\Style\Image as ImageStyle; * * Write common parts of document.xml, headerx.xml, and footerx.xml */ -class Base extends WriterPart +class Base extends AbstractWriterPart { /** * Write text element @@ -1121,9 +1121,9 @@ class Base extends WriterPart * Write container elements * * @param XMLWriter $xmlWriter - * @param Container $container + * @param AbstractElement $container */ - protected function writeContainerElements(XMLWriter $xmlWriter, Container $container) + protected function writeContainerElements(XMLWriter $xmlWriter, AbstractElement $container) { // Check allowed elements $elmCommon = array('Text', 'Link', 'TextBreak', 'Image', 'Object'); diff --git a/src/PhpWord/Writer/Word2007/ContentTypes.php b/src/PhpWord/Writer/Word2007/ContentTypes.php index 8eb10bc1..a27ef43c 100755 --- a/src/PhpWord/Writer/Word2007/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/ContentTypes.php @@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter; /** * Word2007 contenttypes part writer */ -class ContentTypes extends WriterPart +class ContentTypes extends AbstractWriterPart { /** * Write [Content_Types].xml diff --git a/src/PhpWord/Writer/Word2007/DocProps.php b/src/PhpWord/Writer/Word2007/DocProps.php index cfa238e5..5818d511 100644 --- a/src/PhpWord/Writer/Word2007/DocProps.php +++ b/src/PhpWord/Writer/Word2007/DocProps.php @@ -14,7 +14,7 @@ use PhpOffice\PhpWord\PhpWord; /** * Word2007 contenttypes part writer */ -class DocProps extends WriterPart +class DocProps extends AbstractWriterPart { /** * Write docProps/app.xml diff --git a/src/PhpWord/Writer/Word2007/Document.php b/src/PhpWord/Writer/Word2007/Document.php index 2b5e6e95..9cc53375 100644 --- a/src/PhpWord/Writer/Word2007/Document.php +++ b/src/PhpWord/Writer/Word2007/Document.php @@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\TOC; -use PhpOffice\PhpWord\Container\Section; +use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\PageBreak; use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Font; diff --git a/src/PhpWord/Writer/Word2007/Footer.php b/src/PhpWord/Writer/Word2007/Footer.php index 4b075b97..dc726114 100644 --- a/src/PhpWord/Writer/Word2007/Footer.php +++ b/src/PhpWord/Writer/Word2007/Footer.php @@ -9,7 +9,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; -use PhpOffice\PhpWord\Container\Footer as FooterElement; +use PhpOffice\PhpWord\Element\Footer as FooterElement; /** * Word2007 footer part writer diff --git a/src/PhpWord/Writer/Word2007/Header.php b/src/PhpWord/Writer/Word2007/Header.php index 3f649261..95e57340 100644 --- a/src/PhpWord/Writer/Word2007/Header.php +++ b/src/PhpWord/Writer/Word2007/Header.php @@ -9,7 +9,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007; -use PhpOffice\PhpWord\Container\Header as HeaderElement; +use PhpOffice\PhpWord\Element\Header as HeaderElement; /** * Word2007 header part writer diff --git a/src/PhpWord/Writer/Word2007/Rels.php b/src/PhpWord/Writer/Word2007/Rels.php index d7552410..c708eeaf 100755 --- a/src/PhpWord/Writer/Word2007/Rels.php +++ b/src/PhpWord/Writer/Word2007/Rels.php @@ -17,7 +17,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter; * * @since 0.9.2 */ -class Rels extends WriterPart +class Rels extends AbstractWriterPart { /** * Base relationship URL diff --git a/src/PhpWord/Writer/IWriter.php b/src/PhpWord/Writer/WriterInterface.php similarity index 93% rename from src/PhpWord/Writer/IWriter.php rename to src/PhpWord/Writer/WriterInterface.php index ea69b830..2c225b2c 100755 --- a/src/PhpWord/Writer/IWriter.php +++ b/src/PhpWord/Writer/WriterInterface.php @@ -12,7 +12,7 @@ namespace PhpOffice\PhpWord\Writer; /** * Writer interface */ -interface IWriter +interface WriterInterface { /** * Save PhpWord to file diff --git a/tests/PhpWord/Tests/Element/FooterTest.php b/tests/PhpWord/Tests/Element/FooterTest.php index db982dc5..d4201149 100644 --- a/tests/PhpWord/Tests/Element/FooterTest.php +++ b/tests/PhpWord/Tests/Element/FooterTest.php @@ -7,12 +7,12 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Tests\Container; +namespace PhpOffice\PhpWord\Tests\Element; -use PhpOffice\PhpWord\Container\Footer; +use PhpOffice\PhpWord\Element\Footer; /** - * Test class for PhpOffice\PhpWord\Container\Footer + * Test class for PhpOffice\PhpWord\Element\Footer * * @runTestsInSeparateProcesses */ @@ -26,7 +26,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase $iVal = rand(1, 1000); $oFooter = new Footer($iVal); - $this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Footer', $oFooter); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footer', $oFooter); $this->assertEquals($oFooter->getSectionId(), $iVal); } diff --git a/tests/PhpWord/Tests/Element/HeaderTest.php b/tests/PhpWord/Tests/Element/HeaderTest.php index ef1703f3..849dd220 100644 --- a/tests/PhpWord/Tests/Element/HeaderTest.php +++ b/tests/PhpWord/Tests/Element/HeaderTest.php @@ -7,12 +7,12 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Tests\Container; +namespace PhpOffice\PhpWord\Tests\Element; -use PhpOffice\PhpWord\Container\Header; +use PhpOffice\PhpWord\Element\Header; /** - * Test class for PhpOffice\PhpWord\Container\Header + * Test class for PhpOffice\PhpWord\Element\Header * * @runTestsInSeparateProcesses */ @@ -26,7 +26,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase $iVal = rand(1, 1000); $oHeader = new Header($iVal); - $this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Header', $oHeader); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Header', $oHeader); $this->assertEquals($oHeader->getSectionId(), $iVal); $this->assertEquals($oHeader->getType(), Header::AUTO); } diff --git a/tests/PhpWord/Tests/Element/PageBreakTest.php b/tests/PhpWord/Tests/Element/PageBreakTest.php index 3dbaad87..0c6379f5 100644 --- a/tests/PhpWord/Tests/Element/PageBreakTest.php +++ b/tests/PhpWord/Tests/Element/PageBreakTest.php @@ -24,7 +24,6 @@ class PageBreakTest extends \PHPUnit_Framework_TestCase */ public function testConstruct() { - // Section Settings $oPageBreak = new PageBreak(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\PageBreak', $oPageBreak); diff --git a/tests/PhpWord/Tests/Element/SectionTest.php b/tests/PhpWord/Tests/Element/SectionTest.php index e077ff82..d41a1e1f 100644 --- a/tests/PhpWord/Tests/Element/SectionTest.php +++ b/tests/PhpWord/Tests/Element/SectionTest.php @@ -7,15 +7,15 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Tests\Container; +namespace PhpOffice\PhpWord\Tests\Element; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Container\Section; -use PhpOffice\PhpWord\Container\Header; +use PhpOffice\PhpWord\Element\Section; +use PhpOffice\PhpWord\Element\Header; use PhpOffice\PhpWord\Style; /** - * Test class for PhpOffice\PhpWord\Container\Section + * Test class for PhpOffice\PhpWord\Element\Section * * @runTestsInSeparateProcesses */ @@ -139,7 +139,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase foreach ($elements as $element) { $method = "create{$element}"; - $this->assertInstanceOf("PhpOffice\\PhpWord\\Container\\{$element}", $object->$method()); + $this->assertInstanceOf("PhpOffice\\PhpWord\\Element\\{$element}", $object->$method()); } $this->assertFalse($object->hasDifferentFirstPage()); } diff --git a/tests/PhpWord/Tests/MediaTest.php b/tests/PhpWord/Tests/MediaTest.php index 14a38c2d..93dfaf87 100644 --- a/tests/PhpWord/Tests/MediaTest.php +++ b/tests/PhpWord/Tests/MediaTest.php @@ -10,7 +10,7 @@ namespace PhpOffice\PhpWord\Tests; use PhpOffice\PhpWord\Media; -use PhpOffice\PhpWord\Container\Section; +use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\Image; /** diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index 829ddfff..efef7053 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Tests; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\DocumentProperties; -use PhpOffice\PhpWord\Container\Section; +use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Style; /** diff --git a/tests/PhpWord/Tests/Style/SectionTest.php b/tests/PhpWord/Tests/Style/SectionTest.php index 3d5ae43a..542a0f25 100644 --- a/tests/PhpWord/Tests/Style/SectionTest.php +++ b/tests/PhpWord/Tests/Style/SectionTest.php @@ -7,14 +7,14 @@ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL */ -namespace PhpOffice\PhpWord\Tests\Container; +namespace PhpOffice\PhpWord\Tests\Style; -use PhpOffice\PhpWord\Container\Settings; +use PhpOffice\PhpWord\Style\Section; /** - * Test class for PhpOffice\PhpWord\Container\Settings + * Test class for PhpOffice\PhpWord\Style\Section * - * @coversDefaultClass \PhpOffice\PhpWord\Container\Settings + * @coversDefaultClass \PhpOffice\PhpWord\Element\Section * @runTestsInSeparateProcesses */ class SettingsTest extends \PHPUnit_Framework_TestCase @@ -25,7 +25,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testSettingValue() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $oSettings->setSettingValue('_orientation', 'landscape'); $this->assertEquals('landscape', $oSettings->getOrientation()); @@ -63,7 +63,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testMargin() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $iVal = rand(1, 1000); $oSettings->setMarginTop($iVal); @@ -88,7 +88,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testOrientationLandscape() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $oSettings->setLandscape(); $this->assertEquals('landscape', $oSettings->getOrientation()); @@ -102,7 +102,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testOrientationPortrait() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $oSettings->setPortrait(); $this->assertNull($oSettings->getOrientation()); @@ -116,7 +116,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testBorderSize() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $iVal = rand(1, 1000); $oSettings->setBorderSize($iVal); @@ -149,7 +149,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testBorderColor() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $oSettings->setBorderColor('FF00AA'); $this->assertEquals(array('FF00AA', 'FF00AA', 'FF00AA', 'FF00AA'), $oSettings->getBorderColor()); @@ -177,7 +177,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testNumberingStart() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $this->assertNull($oSettings->getPageNumberingStart()); @@ -194,7 +194,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase */ public function testHeader() { - $oSettings = new Settings(); + $oSettings = new Section(); $this->assertEquals(720, $oSettings->getHeaderHeight()); @@ -212,7 +212,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testFooter() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $this->assertEquals(720, $oSettings->getFooterHeight()); @@ -230,7 +230,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testColumnsNum() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); // Default $this->assertEquals(1, $oSettings->getColsNum()); @@ -249,16 +249,16 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testColumnsSpace() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); // Default $this->assertEquals(720, $oSettings->getColsSpace()); $iVal = rand(1, 1000); - $this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Settings', $oSettings->setColsSpace($iVal)); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Section', $oSettings->setColsSpace($iVal)); $this->assertEquals($iVal, $oSettings->getColsSpace()); - $this->assertInstanceOf('PhpOffice\\PhpWord\\Container\\Settings', $oSettings->setColsSpace()); + $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Section', $oSettings->setColsSpace()); $this->assertEquals(720, $oSettings->getColsSpace()); } @@ -268,7 +268,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase public function testBreakType() { // Section Settings - $oSettings = new Settings(); + $oSettings = new Section(); $this->assertNull($oSettings->getBreakType()); diff --git a/tests/PhpWord/Tests/Writer/ODText/WriterPartTest.php b/tests/PhpWord/Tests/Writer/ODText/AbstractWriterPartTest.php similarity index 69% rename from tests/PhpWord/Tests/Writer/ODText/WriterPartTest.php rename to tests/PhpWord/Tests/Writer/ODText/AbstractWriterPartTest.php index 19f17ee5..a8863087 100644 --- a/tests/PhpWord/Tests/Writer/ODText/WriterPartTest.php +++ b/tests/PhpWord/Tests/Writer/ODText/AbstractWriterPartTest.php @@ -12,12 +12,12 @@ use PhpOffice\PhpWord\Writer\ODText; use PhpWord\Tests\TestHelperDOCX; /** - * Test class for PhpOffice\PhpWord\Writer\ODText\WriterPart + * Test class for PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart * - * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\WriterPart + * @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart * @runTestsInSeparateProcesses */ -class WriterPartTest extends \PHPUnit_Framework_TestCase +class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase { /** * covers ::setParentWriter @@ -26,7 +26,7 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase public function testSetGetParentWriter() { $object = $this->getMockForAbstractClass( - 'PhpOffice\\PhpWord\\Writer\\ODText\\WriterPart' + 'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart' ); $object->setParentWriter(new ODText()); $this->assertEquals( @@ -38,12 +38,12 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase /** * covers ::getParentWriter * @expectedException Exception - * @expectedExceptionMessage No parent IWriter assigned. + * @expectedExceptionMessage No parent WriterInterface assigned. */ public function testSetGetParentWriterNull() { $object = $this->getMockForAbstractClass( - 'PhpOffice\\PhpWord\\Writer\\ODText\\WriterPart' + 'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart' ); $object->getParentWriter(); } diff --git a/tests/PhpWord/Tests/Writer/Word2007/WriterPartTest.php b/tests/PhpWord/Tests/Writer/Word2007/AbstractWriterPartTest.php similarity index 66% rename from tests/PhpWord/Tests/Writer/Word2007/WriterPartTest.php rename to tests/PhpWord/Tests/Writer/Word2007/AbstractWriterPartTest.php index 5cbe9eb9..33051d6f 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/WriterPartTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/AbstractWriterPartTest.php @@ -8,17 +8,17 @@ */ namespace PhpOffice\PhpWord\Tests\Writer\Word2007; -use PhpOffice\PhpWord\Writer\Word2007\WriterPart; +use PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart; use PhpOffice\PhpWord\Writer\Word2007; use PhpWord\Tests\TestHelperDOCX; /** - * Test class for PhpOffice\PhpWord\Writer\Word2007\WriterPart + * Test class for PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart * - * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\WriterPart + * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart * @runTestsInSeparateProcesses */ -class WriterPartTest extends \PHPUnit_Framework_TestCase +class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase { /** * covers ::setParentWriter @@ -27,7 +27,7 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase public function testSetGetParentWriter() { $object = $this->getMockForAbstractClass( - 'PhpOffice\\PhpWord\\Writer\\Word2007\\WriterPart' + 'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart' ); $object->setParentWriter(new Word2007()); $this->assertEquals( @@ -39,12 +39,12 @@ class WriterPartTest extends \PHPUnit_Framework_TestCase /** * covers ::getParentWriter * @expectedException Exception - * @expectedExceptionMessage No parent IWriter assigned. + * @expectedExceptionMessage No parent WriterInterface assigned. */ public function testSetGetParentWriterNull() { $object = $this->getMockForAbstractClass( - 'PhpOffice\\PhpWord\\Writer\\Word2007\\WriterPart' + 'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart' ); $object->getParentWriter(); } diff --git a/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php b/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php index 04e86832..b1bff02b 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/FooterTest.php @@ -28,7 +28,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase public function testWriteFooter() { $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png"; - $container = new \PhpOffice\PhpWord\Container\Footer(1); + $container = new \PhpOffice\PhpWord\Element\Footer(1); $container->addText(''); $container->addPreserveText(''); $container->addTextBreak(); diff --git a/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php b/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php index c468d7a7..b836b619 100644 --- a/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php +++ b/tests/PhpWord/Tests/Writer/Word2007/HeaderTest.php @@ -26,7 +26,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase { $imageSrc = __DIR__ . "/../../_files/images/PhpWord.png"; - $container = new \PhpOffice\PhpWord\Container\Header(1); + $container = new \PhpOffice\PhpWord\Element\Header(1); $container->addText('Test'); $container->addPreserveText(''); $container->addTextBreak();