Method name & code format for PSR/phpdoc compliance

This commit is contained in:
Ivan Lanin 2014-03-24 00:26:10 +07:00
parent d7a66ca15e
commit aff112a13b
85 changed files with 1162 additions and 71 deletions

View File

@ -8,7 +8,7 @@ This release marked the transformation to namespaces (PHP 5.3+).
### Features
None yet
None yet.
### Bugfixes
@ -16,7 +16,11 @@ None yet
### Miscellaneous
- Documentation - @Progi1984
- Move documentation to [Read The Docs](http://phpword.readthedocs.org/en/develop/) - @Progi1984 @ivanlanin GH-82
- Reorganize and redesign samples folder - @ivanlanin GH-137
- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58
- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull
- Compliance to phpDocumentor - @ivanlanin
## 0.8.1 - 17 Mar 2014

View File

@ -47,11 +47,13 @@ Manual install
To install manually, `download PHPWord package from
github <https://github.com/PHPOffice/PHPWord/archive/master.zip>`__.
Extract the package and put the contents to your machine. To use the
library, include ``src/PhpWord/PhpWord.php`` in your script like below.
library, include ``src/PhpWord/Autoloader.php`` in your script and
invoke ``Autoloader::register``.
.. code-block:: php
require_once '/path/to/src/PhpWord/PhpWord.php';
require_once '/path/to/src/PhpWord/Autoloader.php';
PhpOffice\PhpWord\Autoloader::register();
Using samples
-------------

View File

@ -53,7 +53,7 @@ $document->setValue('userFirstName#3', 'Michael');
$document->setValue('userName#3', 'Ray');
$document->setValue('userPhone#3', '+1 428 889 775');
$name = 'Sample_07_TemplateCloneRow_result.docx';
$name = 'Sample_07_TemplateCloneRow.docx';
echo date('H:i:s'), " Write to Word2007 format", \EOL;
$document->saveAs($name);
rename($name, "results/{$name}");

View File

@ -5,7 +5,10 @@
error_reporting(E_ALL);
define('CLI', (PHP_SAPI == 'cli') ? true : false);
define('EOL', CLI ? PHP_EOL : '<br />');
require_once '../src/PhpWord/PhpWord.php';
require_once '../src/PhpWord/Autoloader.php';
PhpOffice\PhpWord\Autoloader::register();
// Return to the caller script when runs by CLI
if (CLI) {
return;

View File

@ -25,11 +25,16 @@
namespace PhpOffice\PhpWord;
/**
* Autoloader
*/
class Autoloader
{
const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\';
/**
* Register
*
* @return void
*/
public static function register()
@ -38,6 +43,8 @@ class Autoloader
}
/**
* Autoload
*
* @param string $class
*/
public static function autoload($class)
@ -51,4 +58,4 @@ class Autoloader
}
}
}
}
}

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord;
/**
* Document properties
*/
class DocumentProperties
{
/** Constants */

View File

@ -26,6 +26,9 @@
*/
namespace PhpOffice\PhpWord\Exceptions;
/**
* General exception
*/
class Exception extends \Exception
{
}

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord;
/**
* Footnote
*/
class Footnote
{
/**

View File

@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exceptions\Exception;
/**
* Hash table
*
* @codeCoverageIgnore Legacy from PHPExcel
*/
class HashTable
@ -47,6 +49,8 @@ class HashTable
public $_keyMap = array();
/**
* Create new
*
* @param \PhpOffice\PhpWord\IComparable[] $pSource Optional source array to create HashTable from
*/
public function __construct($pSource = null)
@ -140,6 +144,8 @@ class HashTable
}
/**
* Get item count
*
* @return int
*/
public function count()
@ -148,6 +154,8 @@ class HashTable
}
/**
* Get hash code index
*
* @param string $pHashCode
* @return int Index
*/
@ -157,6 +165,8 @@ class HashTable
}
/**
* Get by index
*
* @param int $pIndex
* @return \PhpOffice\PhpWord\IComparable
*/
@ -170,6 +180,7 @@ class HashTable
}
/**
* Get by hashcode
* @param string $pHashCode
* @return \PhpOffice\PhpWord\IComparable
*
@ -184,6 +195,8 @@ class HashTable
}
/**
* Convert to array
*
* @return \PhpOffice\PhpWord\IComparable[]
*/
public function toArray()

View File

@ -27,9 +27,14 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exceptions\Exception;
/**
* IO factory
*/
abstract class IOFactory
{
/**
* Create new writer
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $name
* @return \PhpOffice\PhpWord\Writer\IWriter
@ -46,6 +51,8 @@ abstract class IOFactory
}
/**
* Create new reader
*
* @param string $name
* @return \PhpOffice\PhpWord\Reader\IReader
* @throws \PhpOffice\PhpWord\Exceptions\Exception

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Section\MemoryImage;
/**
* Media
*/
class Media
{
/**

View File

@ -31,6 +31,9 @@ use PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Template;
/**
* PhpWord main class
*/
class PhpWord
{
const DEFAULT_FONT_COLOR = '000000'; // HEX
@ -45,25 +48,35 @@ class PhpWord
const DEFAULT_FONT_SIZE = 10;
/**
* Document properties object
*
* @var \PhpOffice\PhpWord\DocumentProperties
*/
private $_documentProperties;
/**
* Default font name
*
* @var string
*/
private $_defaultFontName;
/**
* Default font size
* @var int
*/
private $_defaultFontSize;
/**
* Collection of sections
*
* @var \PhpOffice\PhpWord\Section[]
*/
private $_sections = array();
/**
* Create new
*/
public function __construct()
{
$this->_documentProperties = new DocumentProperties();
@ -72,6 +85,8 @@ class PhpWord
}
/**
* Get document properties object
*
* @return \PhpOffice\PhpWord\DocumentProperties
*/
public function getDocumentProperties()
@ -80,6 +95,8 @@ class PhpWord
}
/**
* Set document properties object
*
* @param \PhpOffice\PhpWord\DocumentProperties $documentProperties
* @return \PhpOffice\PhpWord\PhpWord
*/
@ -91,6 +108,8 @@ class PhpWord
}
/**
* Create new section
*
* @param \PhpOffice\PhpWord\Section\Settings $settings
* @return \PhpOffice\PhpWord\Section
*/
@ -103,6 +122,8 @@ class PhpWord
}
/**
* Get default font name
*
* @return string
*/
public function getDefaultFontName()
@ -111,6 +132,8 @@ class PhpWord
}
/**
* Set default font name
*
* @param string $fontName
*/
public function setDefaultFontName($fontName)
@ -119,6 +142,8 @@ class PhpWord
}
/**
* Get default font size
*
* @return string
*/
public function getDefaultFontSize()
@ -127,6 +152,8 @@ class PhpWord
}
/**
* Set default font size
*
* @param int $fontSize
*/
public function setDefaultFontSize($fontSize)
@ -159,7 +186,8 @@ class PhpWord
* Adds a font style definition to styles.xml
*
* @param $styleName string
* @param $styles array
* @param mixed $styleFont
* @param mixed $styleParagraph
*/
public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
{
@ -169,8 +197,9 @@ class PhpWord
/**
* Adds a table style definition to styles.xml
*
* @param $styleName string
* @param $styles array
* @param string $styleName
* @param mixed $styleTable
* @param mixed $styleFirstRow
*/
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
{
@ -180,8 +209,9 @@ class PhpWord
/**
* Adds a heading style definition to styles.xml
*
* @param $titleCount int
* @param $styles array
* @param int $titleCount
* @param mixed $styleFont
* @param mixed $styleParagraph
*/
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
{
@ -191,8 +221,8 @@ class PhpWord
/**
* Adds a hyperlink style to styles.xml
*
* @param $styleName string
* @param $styles array
* @param string $styleName
* @param mixed $styles
*/
public function addLinkStyle($styleName, $styles)
{
@ -200,6 +230,8 @@ class PhpWord
}
/**
* Get all sections
*
* @return \PhpOffice\PhpWord\Section[]
*/
public function getSections()
@ -208,6 +240,8 @@ class PhpWord
}
/**
* Load template by filename
*
* @param string $filename Fully qualified filename.
* @return \PhpOffice\PhpWord\Template
* @throws \PhpOffice\PhpWord\Exceptions\Exception

View File

@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord\Reader;
use PhpOffice\PhpWord\Exceptions\Exception;
/**
* Reader abstract class
*
* @codeCoverageIgnore Abstract class
*/
abstract class AbstractReader implements IReader
@ -79,7 +81,7 @@ abstract class AbstractReader implements IReader
protected function openFile($pFilename)
{
// Check if file exists
if (!file_exists($pFilename) || !is_readable($pFilename)) {
if (!\file_exists($pFilename) || !is_readable($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Reader;
/**
* Reader interface
*/
interface IReader
{
/**

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\DocumentProperties;
use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\File;
/**
* Reader for Word2007
*/
class Word2007 extends AbstractReader implements IReader
{
/**
@ -42,7 +45,7 @@ class Word2007 extends AbstractReader implements IReader
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
if (!\file_exists($pFilename)) {
throw new Exception("Could not open {$pFilename} for reading! File does not exist.");
}
@ -71,6 +74,8 @@ class Word2007 extends AbstractReader implements IReader
}
/**
* Get zip content
*
* @param \ZipArchive $archive
* @param string $fileName
* @param bool $removeNamespace
@ -434,6 +439,8 @@ class Word2007 extends AbstractReader implements IReader
}
/**
* Return item of array
*
* @param array $array
* @param mixed $key
* @return mixed|null

View File

@ -42,6 +42,9 @@ use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Section\Title;
use PhpOffice\PhpWord\Shared\String;
/**
* Section
*/
class Section
{
/**
@ -241,7 +244,7 @@ class Section
}
$iconSrc = __DIR__ . '/_staticDocParts/';
if (!file_exists($iconSrc . '_' . $ext . '.png')) {
if (!\file_exists($iconSrc . '_' . $ext . '.png')) {
$iconSrc = $iconSrc . '_default.png';
} else {
$iconSrc .= '_' . $ext . '.png';
@ -425,6 +428,8 @@ class Section
}
/**
* Get footer element
*
* @return \PhpOffice\PhpWord\Section\Footer
*/
public function getFooter()

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Section\Footer\PreserveText;
use PhpOffice\PhpWord\Shared\String;
/**
* Footer element
*/
class Footer
{
/**
@ -55,6 +58,8 @@ class Footer
/**
* Create a new Footer
*
* @param int $sectionCount
*/
public function __construct($sectionCount)
{
@ -96,6 +101,7 @@ class Footer
/**
* Create a new TextRun
*
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\TextRun
*/
public function createTextRun($styleParagraph = null)

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section\Footer;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Preserve text/field element
*/
class PreserveText
{
/**

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Footnote element
*/
class Footnote
{
/**
@ -52,6 +55,8 @@ class Footnote
/**
* Create a new Footnote Element
*
* @param mixed $styleParagraph
*/
public function __construct($styleParagraph = null)
{
@ -76,8 +81,8 @@ class Footnote
/**
* Add a Text Element
*
* @var string $text
* @var mixed $styleFont
* @param string $text
* @param mixed $styleFont
* @return \PhpOffice\PhpWord\Section\Text
*/
public function addText($text = null, $styleFont = null)
@ -118,6 +123,8 @@ class Footnote
}
/**
* Get paragraph style
*
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
public function getParagraphStyle()

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Section\Footer\PreserveText;
use PhpOffice\PhpWord\Shared\String;
/**
* Header element
*/
class Header
{
/**
@ -84,6 +87,8 @@ class Header
/**
* Create a new Header
*
* @param int $sectionCount
*/
public function __construct($sectionCount)
{
@ -125,6 +130,7 @@ class Header
/**
* Create a new TextRun
*
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\TextRun
*/
public function createTextRun($styleParagraph = null)

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException;
/**
* Image element
*/
class Image
{
/**
@ -72,7 +75,7 @@ class Image
{
$supportedImageTypes = array(\IMAGETYPE_JPEG, \IMAGETYPE_GIF, \IMAGETYPE_PNG, \IMAGETYPE_BMP, \IMAGETYPE_TIFF_II, \IMAGETYPE_TIFF_MM);
if (!file_exists($src)) {
if (!\file_exists($src)) {
throw new InvalidImageException;
}

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Link element
*/
class Link
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section;
/**
* List item element
*/
class ListItem
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section;
/**
* Memory image element
*/
class MemoryImage
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section;
/**
* Object element
*/
class Object
{
/**
@ -74,7 +77,7 @@ class Object
$_supportedObjectTypes = array('xls', 'doc', 'ppt');
$inf = pathinfo($src);
if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
if (\file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) {
$this->_src = $src;
$this->_style = new \PhpOffice\PhpWord\Style\Image();

View File

@ -25,8 +25,14 @@
namespace PhpOffice\PhpWord\Section;
/**
* Page break element
*/
class PageBreak
{
/**
* Create new page break
*/
public function __construct()
{
}

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section;
/**
* Section settings
*/
class Settings
{
/**

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Section\Table\Row;
/**
* Table element
*/
class Table
{
/**

View File

@ -38,6 +38,9 @@ use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Shared\String;
/**
* Table cell element
*/
class Cell
{
/**
@ -109,7 +112,8 @@ class Cell
* Add a Text Element
*
* @param string $text
* @param mixed $style
* @param mixed $styleFont
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\Text
*/
public function addText($text, $styleFont = null, $styleParagraph = null)
@ -261,7 +265,7 @@ class Cell
}
$iconSrc = __DIR__ . '/../../_staticDocParts/';
if (!file_exists($iconSrc . '_' . $ext . '.png')) {
if (!\file_exists($iconSrc . '_' . $ext . '.png')) {
$iconSrc = $iconSrc . '_default.png';
} else {
$iconSrc .= '_' . $ext . '.png';
@ -308,6 +312,7 @@ class Cell
/**
* Create a new TextRun
*
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\TextRun
*/
public function createTextRun($styleParagraph = null)

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section\Table;
/**
* Table row element
*/
class Row
{
/**

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Text element
*/
class Text
{
/**

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Text break element
*/
class TextBreak
{
/**
@ -46,6 +49,9 @@ class TextBreak
/**
* Create a new TextBreak Element
*
* @param mixed $fontStyle
* @param mixed $paragraphStyle
*/
public function __construct($fontStyle = null, $paragraphStyle = null)
{

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media;
use PhpOffice\PhpWord\Shared\String;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Textrun/paragraph element
*/
class TextRun
{
/**
@ -49,6 +52,8 @@ class TextRun
/**
* Create a new TextRun Element
*
* @param mixed $styleParagraph
*/
public function __construct($styleParagraph = null)
{
@ -73,8 +78,8 @@ class TextRun
/**
* Add a Text Element
*
* @var string $text
* @var mixed $styleFont
* @param string $text
* @param mixed $styleFont
* @return \PhpOffice\PhpWord\Section\Text
*/
public function addText($text = null, $styleFont = null)
@ -114,7 +119,7 @@ class TextRun
* Add a Image Element
*
* @param string $imageSrc
* @param mixed $styleFont
* @param mixed $style
* @return \PhpOffice\PhpWord\Section\Image
*/
public function addImage($imageSrc, $style = null)
@ -149,7 +154,7 @@ class TextRun
/**
* Create a new Footnote Element
*
* @param string $text
* @param mixed $styleParagraph
* @return \PhpOffice\PhpWord\Section\Footnote
*/
public function createFootnote($styleParagraph = null)

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Section;
/**
* Title element
*/
class Title
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord;
/**
* Settings
*/
class Settings
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared;
/**
* Common drawing functions
*/
class Drawing
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared;
/**
* Common file functions
*/
class File
{
/**
@ -33,10 +36,10 @@ class File
* @param string $pFilename Filename
* @return bool
*/
public static function file_exists($pFilename)
public static function fileExists($pFilename)
{
// Regular file_exists
return file_exists($pFilename);
return \file_exists($pFilename);
}
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared;
/**
* Common font functions
*/
class Font
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Shared;
/**
* Common string functions
*/
class String
{
/**

View File

@ -32,6 +32,8 @@ if (!defined('DATE_W3C')) {
}
/**
* XMLWriter wrapper
*
* @method bool startElement(string $name)
* @method bool writeAttribute(string $name, string $value)
* @method bool endElement()
@ -57,6 +59,8 @@ class XMLWriter
private $_tempFileName = '';
/**
* Create new XMLWriter
*
* @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageFolder Temporary storage folder
*/

View File

@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord\Shared;
use PhpOffice\PhpWord\Exceptions\Exception;
/**
* Zip stream wrapper
*
* @codeCoverageIgnore Legacy from PHPExcel
*/
class ZipStreamWrapper
@ -77,7 +79,7 @@ class ZipStreamWrapper
* @param string $options
* @param string $opened_path
*/
public function stream_open($path, $mode, $options, &$opened_path)
public function streamOpen($path, $mode, $options, &$opened_path)
{
// Check for mode
if ($mode{0} != 'r') {
@ -117,7 +119,7 @@ class ZipStreamWrapper
/**
* Stat stream
*/
public function stream_stat()
public function streamStat()
{
return $this->_archive->statName($this->_fileNameInArchive);
}
@ -127,7 +129,7 @@ class ZipStreamWrapper
*
* @param int $count
*/
public function stream_read($count)
public function streamRead($count)
{
$ret = substr($this->_data, $this->_position, $count);
$this->_position += strlen($ret);
@ -137,7 +139,7 @@ class ZipStreamWrapper
/**
* Tell stream
*/
public function stream_tell()
public function streamTell()
{
return $this->_position;
}
@ -145,7 +147,7 @@ class ZipStreamWrapper
/**
* EOF stream
*/
public function stream_eof()
public function streamEof()
{
return $this->_position >= strlen($this->_data);
}
@ -156,7 +158,7 @@ class ZipStreamWrapper
* @param int $offset
* @param mixed $whence
*/
public function stream_seek($offset, $whence)
public function streamSeek($offset, $whence)
{
switch ($whence) {
case \SEEK_SET:

View File

@ -29,14 +29,21 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull;
/**
* Style
*/
class Style
{
/**
* Style register
*
* @var array
*/
private static $_styleElements = array();
/**
* Add paragraph style
*
* @param string $styleName
* @param array $styles
*/
@ -56,6 +63,8 @@ class Style
}
/**
* Add font style
*
* @param string $styleName
* @param array $styleFont
* @param array $styleParagraph
@ -75,6 +84,8 @@ class Style
}
/**
* Add link style
*
* @param string $styleName
* @param array $styles
*/
@ -94,8 +105,11 @@ class Style
}
/**
* Add table style
*
* @param string $styleName
* @param array $styles
* @param array $styleTable
* @param array $styleFirstRow
*/
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
{
@ -107,7 +121,9 @@ class Style
}
/**
* @param string $styleName
* Add title style
*
* @param int $titleCount
* @param array $styleFont
* @param array $styleParagraph
*/
@ -128,6 +144,8 @@ class Style
}
/**
* Set default paragraph style
*
* @param array $styles Paragraph style definition
*/
public static function setDefaultParagraphStyle($styles)
@ -146,7 +164,9 @@ class Style
}
/**
* @param string
* Get style by name
*
* @param string $styleName
*/
public static function getStyle($styleName)
{

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style;
/**
* Table cell style
*/
class Cell
{
const TEXT_DIR_BTLR = 'btLr';

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/**
* Font style
*/
class Font
{
const UNDERLINE_NONE = 'none';
@ -72,6 +75,8 @@ class Font
private $_type;
/**
* Paragraph style
*
* @var \PhpOffice\PhpWord\Style\Paragraph
*/
private $_paragraphStyle;
@ -91,31 +96,43 @@ class Font
private $_size = PhpWord::DEFAULT_FONT_SIZE;
/**
* Bold
*
* @var bool
*/
private $_bold = false;
/**
* Italic
*
* @var bool
*/
private $_italic = false;
/**
* Superscript
*
* @var bool
*/
private $_superScript = false;
/**
* Subscript
*
* @var bool
*/
private $_subScript = false;
/**
* Undeline
*
* @var string
*/
private $_underline = self::UNDERLINE_NONE;
/**
* Strikethrough
*
* @var bool
*/
private $_strikethrough = false;
@ -149,6 +166,8 @@ class Font
private $_hint = PhpWord::DEFAULT_FONT_CONTENT_TYPE;
/**
* Create new font style
*
* @param string $type Type of font
* @param array $paragraphStyle Paragraph styles definition
*/
@ -188,6 +207,8 @@ class Font
}
/**
* Set style value
*
* @param string $key
* @param mixed $value
*/
@ -251,6 +272,8 @@ class Font
}
/**
* Get bold
*
* @return bool
*/
public function getBold()
@ -259,6 +282,8 @@ class Font
}
/**
* Set bold
*
* @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font
*/
@ -272,6 +297,8 @@ class Font
}
/**
* Get italic
*
* @return bool
*/
public function getItalic()
@ -280,6 +307,8 @@ class Font
}
/**
* Set italic
*
* @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font
*/
@ -293,6 +322,8 @@ class Font
}
/**
* Get superscript
*
* @return bool
*/
public function getSuperScript()
@ -301,6 +332,8 @@ class Font
}
/**
* Set superscript
*
* @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font
*/
@ -315,6 +348,8 @@ class Font
}
/**
* Get subscript
*
* @return bool
*/
public function getSubScript()
@ -323,6 +358,8 @@ class Font
}
/**
* Set subscript
*
* @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font
*/
@ -337,6 +374,8 @@ class Font
}
/**
* Get underline
*
* @return string
*/
public function getUnderline()
@ -345,6 +384,8 @@ class Font
}
/**
* Set underline
*
* @param string $pValue
* @return \PhpOffice\PhpWord\Style\Font
*/
@ -358,6 +399,8 @@ class Font
}
/**
* Get strikethrough
*
* @return bool
*/
public function getStrikethrough()
@ -366,6 +409,8 @@ class Font
}
/**
* Set strikethrough
*
* @param bool $pValue
* @return \PhpOffice\PhpWord\Style\Font
*/
@ -389,6 +434,8 @@ class Font
}
/**
* Set font color
*
* @param string $pValue
* @return \PhpOffice\PhpWord\Style\Font
*/
@ -424,6 +471,8 @@ class Font
}
/**
* Get style type
*
* @return string
*/
public function getStyleType()
@ -432,6 +481,8 @@ class Font
}
/**
* Get paragraph style
*
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
public function getParagraphStyle()
@ -440,6 +491,8 @@ class Font
}
/**
* Set lineheight
*
* @param int|float|string $lineHeight
* @return $this
* @throws \PhpOffice\PhpWord\Exceptions\InvalidStyleException

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style;
/**
* Image and memory image style
*/
class Image
{
const WRAPPING_STYLE_INLINE = 'inline';
@ -76,7 +79,7 @@ class Image
private $_marginLeft;
/**
* Constructor
* Create new image style
*/
public function __construct()
{

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style;
/**
* List item style
*/
class ListItem
{
const TYPE_NUMBER = 7;

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/**
* Paragraph style
*/
class Paragraph
{
const LINE_HEIGHT = 240;
@ -130,6 +133,8 @@ class Paragraph
private $_pageBreakBefore = false;
/**
* Set style by array
*
* @param array $style
* @return $this
*/
@ -316,11 +321,11 @@ class Paragraph
return $this->_tabs;
}
/*
/**
* Set tabs
*
* @param array $pValue
* @return \PhpOffice\PhpWord\Style\Paragraph
* @param array $pValue
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
public function setTabs($pValue = null)
{
@ -497,6 +502,8 @@ class Paragraph
}
/**
* Get line height
*
* @return int|float
*/
public function getLineHeight()

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style;
/**
* Table row style
*/
class Row
{
/**

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style;
/**
* TOC style
*/
class TOC
{
const TABLEADER_DOT = 'dot';

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Tab style
*/
class Tab
{
/**

View File

@ -25,13 +25,42 @@
namespace PhpOffice\PhpWord\Style;
/**
* Table style
*/
class Table
{
private $_cellMarginTop;
private $_cellMarginLeft;
private $_cellMarginRight;
private $_cellMarginBottom;
/**
* Cell margin top
*
* @var int
*/
private $_cellMarginTop = null;
/**
* Cell margin left
*
* @var int
*/
private $_cellMarginLeft = null;
/**
* Cell margin right
*
* @var int
*/
private $_cellMarginRight = null;
/**
* Cell margin bottom
*
* @var int
*/
private $_cellMarginBottom = null;
/**
* Create new table style
*/
public function __construct()
{
$this->_cellMarginTop = null;
@ -40,51 +69,115 @@ class Table
$this->_cellMarginBottom = null;
}
/**
* Set style value
*
* @param string $key
* @param mixed $value
*/
public function setStyleValue($key, $value)
{
$this->$key = $value;
}
/**
* Set cell margin top
*
* @param int $pValue
*/
public function setCellMarginTop($pValue = null)
{
$this->_cellMarginTop = $pValue;
}
/**
* Get cell margin top
*
* @return int
*/
public function getCellMarginTop()
{
return $this->_cellMarginTop;
}
/**
* Set cell margin left
*
* @param int $pValue
*/
public function setCellMarginLeft($pValue = null)
{
$this->_cellMarginLeft = $pValue;
}
/**
* Get cell margin left
*
* @return int
*/
public function getCellMarginLeft()
{
return $this->_cellMarginLeft;
}
/**
* Set cell margin right
*
* @param int $pValue
*/
public function setCellMarginRight($pValue = null)
{
$this->_cellMarginRight = $pValue;
}
/**
* Get cell margin right
*
* @return int
*/
public function getCellMarginRight()
{
return $this->_cellMarginRight;
}
/**
* Set cell margin bottom
*
* @param int $pValue
*/
public function setCellMarginBottom($pValue = null)
{
$this->_cellMarginBottom = $pValue;
}
/**
* Get cell margin bottom
*
* @return int
*/
public function getCellMarginBottom()
{
return $this->_cellMarginBottom;
}
/**
* Set TLRB cell margin
*
* @param int $pValue Margin in twips
*/
public function setCellMargin($pValue = null)
{
$this->_cellMarginTop = $pValue;
$this->_cellMarginLeft = $pValue;
$this->_cellMarginRight = $pValue;
$this->_cellMarginBottom = $pValue;
}
/**
* Get cell margin
*
* @return array
*/
public function getCellMargin()
{
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);

View File

@ -25,6 +25,9 @@
namespace PhpOffice\PhpWord\Style;
/**
* Table (full) style
*/
class TableFull
{
/**
@ -35,90 +38,130 @@ class TableFull
private $_firstRow = null;
/**
* Cell margin top
*
* @var int
*/
private $_cellMarginTop = null;
/**
* Cell margin left
*
* @var int
*/
private $_cellMarginLeft = null;
/**
* Cell margin right
*
* @var int
*/
private $_cellMarginRight = null;
/**
* Cell margin bottom
*
* @var int
*/
private $_cellMarginBottom = null;
/**
* Background color
*
* @var string
*/
private $_bgColor;
/**
* Border size top
*
* @var int
*/
private $_borderTopSize;
/**
* @var string
* Border color
*
* @var string top
*/
private $_borderTopColor;
/**
* Border size left
*
* @var int
*/
private $_borderLeftSize;
/**
* Border color left
*
* @var string
*/
private $_borderLeftColor;
/**
* Border size right
*
* @var int
*/
private $_borderRightSize;
/**
* Border color right
*
* @var string
*/
private $_borderRightColor;
/**
* Border size bottom
*
* @var int
*/
private $_borderBottomSize;
/**
* Border color bottom
*
* @var string
*/
private $_borderBottomColor;
/**
* Border size inside horizontal
*
* @var int
*/
private $_borderInsideHSize;
/**
* Border color inside horizontal
*
* @var string
*/
private $_borderInsideHColor;
/**
* Border size inside vertical
*
* @var int
*/
private $_borderInsideVSize;
/**
* Border color inside vertical
*
* @var string
*/
private $_borderInsideVColor;
/**
* Create new table style
*
* @param mixed $styleTable
* @param mixed $styleFirstRow
*/
public function __construct($styleTable = null, $styleFirstRow = null)
{
if (!is_null($styleFirstRow) && is_array($styleFirstRow)) {
@ -153,6 +196,8 @@ class TableFull
}
/**
* Set style value
*
* @param string $key
* @param mixed $value
*/
@ -189,11 +234,22 @@ class TableFull
return $this->_lastRow;
}
/**
* Get background
*
* @return \PhpOffice\PhpWord\Style\TableFull
*/
public function getBgColor()
{
return $this->_bgColor;
}
/**
* Set background
*
* @param string $pValue
* @return \PhpOffice\PhpWord\Style\TableFull
*/
public function setBgColor($pValue = null)
{
$this->_bgColor = $pValue;
@ -202,7 +258,7 @@ class TableFull
/**
* Set TLRBVH Border Size
*
* @param int $pValue Border size in eighths of a point (1/8 point)
* @param int $pValue Border size in eighths of a point (1/8 point)
*/
public function setBorderSize($pValue = null)
{
@ -233,6 +289,7 @@ class TableFull
/**
* Set TLRBVH Border Color
* @param string $pValue
*/
public function setBorderColor($pValue = null)
{
@ -261,161 +318,321 @@ class TableFull
return array($t, $l, $r, $b, $h, $v);
}
/**
* Set border size top
*
* @param $pValue
*/
public function setBorderTopSize($pValue = null)
{
$this->_borderTopSize = $pValue;
}
/**
* Get border size top
*
* @return
*/
public function getBorderTopSize()
{
return $this->_borderTopSize;
}
/**
* Set border color top
*
* @param $pValue
*/
public function setBorderTopColor($pValue = null)
{
$this->_borderTopColor = $pValue;
}
/**
* Get border color top
*
* @return
*/
public function getBorderTopColor()
{
return $this->_borderTopColor;
}
/**
* Set border size left
*
* @param $pValue
*/
public function setBorderLeftSize($pValue = null)
{
$this->_borderLeftSize = $pValue;
}
/**
* Get border size left
*
* @return
*/
public function getBorderLeftSize()
{
return $this->_borderLeftSize;
}
/**
* Set border color left
*
* @param $pValue
*/
public function setBorderLeftColor($pValue = null)
{
$this->_borderLeftColor = $pValue;
}
/**
* Get border color left
*
* @return
*/
public function getBorderLeftColor()
{
return $this->_borderLeftColor;
}
/**
* Set border size right
*
* @param $pValue
*/
public function setBorderRightSize($pValue = null)
{
$this->_borderRightSize = $pValue;
}
/**
* Get border size right
*
* @return
*/
public function getBorderRightSize()
{
return $this->_borderRightSize;
}
/**
* Set border color right
*
* @param $pValue
*/
public function setBorderRightColor($pValue = null)
{
$this->_borderRightColor = $pValue;
}
/**
* Get border color right
*
* @return
*/
public function getBorderRightColor()
{
return $this->_borderRightColor;
}
/**
* Set border size bottom
*
* @param $pValue
*/
public function setBorderBottomSize($pValue = null)
{
$this->_borderBottomSize = $pValue;
}
/**
* Get border size bottom
*
* @return
*/
public function getBorderBottomSize()
{
return $this->_borderBottomSize;
}
/**
* Set border color bottom
*
* @param $pValue
*/
public function setBorderBottomColor($pValue = null)
{
$this->_borderBottomColor = $pValue;
}
/**
* Get border color bottom
*
* @return
*/
public function getBorderBottomColor()
{
return $this->_borderBottomColor;
}
/**
* Set border color inside horizontal
*
* @param $pValue
*/
public function setBorderInsideHColor($pValue = null)
{
$this->_borderInsideHColor = $pValue;
}
/**
* Get border color inside horizontal
*
* @return
*/
public function getBorderInsideHColor()
{
return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null;
}
/**
* Set border color inside vertical
*
* @param $pValue
*/
public function setBorderInsideVColor($pValue = null)
{
$this->_borderInsideVColor = $pValue;
}
/**
* Get border color inside vertical
*
* @return
*/
public function getBorderInsideVColor()
{
return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null;
}
/**
* Set border size inside horizontal
*
* @param $pValue
*/
public function setBorderInsideHSize($pValue = null)
{
$this->_borderInsideHSize = $pValue;
}
/**
* Get border size inside horizontal
*
* @return
*/
public function getBorderInsideHSize()
{
return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null;
}
/**
* Set border size inside vertical
*
* @param $pValue
*/
public function setBorderInsideVSize($pValue = null)
{
$this->_borderInsideVSize = $pValue;
}
/**
* Get border size inside vertical
*
* @return
*/
public function getBorderInsideVSize()
{
return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null;
}
/**
* Set cell margin top
*
* @param int $pValue
*/
public function setCellMarginTop($pValue = null)
{
$this->_cellMarginTop = $pValue;
}
/**
* Get cell margin top
*
* @return int
*/
public function getCellMarginTop()
{
return $this->_cellMarginTop;
}
/**
* Set cell margin left
*
* @param int $pValue
*/
public function setCellMarginLeft($pValue = null)
{
$this->_cellMarginLeft = $pValue;
}
/**
* Get cell margin left
*
* @return int
*/
public function getCellMarginLeft()
{
return $this->_cellMarginLeft;
}
/**
* Set cell margin right
*
* @param int $pValue
*/
public function setCellMarginRight($pValue = null)
{
$this->_cellMarginRight = $pValue;
}
/**
* Get cell margin right
*
* @return int
*/
public function getCellMarginRight()
{
return $this->_cellMarginRight;
}
/**
* Set cell margin bottom
*
* @param int $pValue
*/
public function setCellMarginBottom($pValue = null)
{
$this->_cellMarginBottom = $pValue;
}
/**
* Get cell margin bottom
*
* @return int
*/
public function getCellMarginBottom()
{
return $this->_cellMarginBottom;
@ -424,7 +641,7 @@ class TableFull
/**
* Set TLRB cell margin
*
* @param int $pValue Margin in twips
* @param int $pValue Margin in twips
*/
public function setCellMargin($pValue = null)
{
@ -434,6 +651,11 @@ class TableFull
$this->_cellMarginBottom = $pValue;
}
/**
* Get cell margin
*
* @return array
*/
public function getCellMargin()
{
return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom);

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Tabs style
*/
class Tabs
{
/**
@ -37,6 +40,7 @@ class Tabs
private $_tabs;
/**
* Create new tab collection style
*
* @param array $tabs
*/
@ -46,6 +50,8 @@ class Tabs
}
/**
* Return XML
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
*/
public function toXml(XMLWriter &$xmlWriter = null)

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Style\Font;
/**
* Table of contents
*/
class TOC
{
/**

View File

@ -28,19 +28,28 @@ namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\String;
/**
* Template
*/
class Template
{
/**
* ZipArchive object
*
* @var \ZipArchive
*/
private $_objZip;
/**
* Temporary file name
*
* @var string
*/
private $_tempFileName;
/**
* Document XML
*
* @var string
*/
private $_documentXML;
@ -249,6 +258,8 @@ class Template
}
/**
* Save XML to temporary file
*
* @return string
* @throws \PhpOffice\PhpWord\Exceptions\Exception
*/
@ -265,13 +276,15 @@ class Template
}
/**
* Save XML to defined name
*
* @param string $strFilename
*/
public function saveAs($strFilename)
{
$tempFilename = $this->save();
if (file_exists($strFilename)) {
if (\file_exists($strFilename)) {
unlink($strFilename);
}

View File

@ -25,12 +25,15 @@
namespace PhpOffice\PhpWord\Writer;
/**
* Writer interface
*/
interface IWriter
{
/**
* Save PhpWord to file
*
* @param string $pFileName
* @param string $pFilename
*/
public function save($pFilename = null);
}

View File

@ -34,14 +34,21 @@ use PhpOffice\PhpWord\Writer\ODText\Meta;
use PhpOffice\PhpWord\Writer\ODText\Mimetype;
use PhpOffice\PhpWord\Writer\ODText\Styles;
/**
* ODText writer
*/
class ODText implements IWriter
{
/**
* PhpWord object
*
* @var \PhpOffice\PhpWord\PhpWord
*/
private $_document;
/**
* Individual writers
*
* @var \PhpOffice\PhpWord\Writer\ODText\WriterPart[]
*/
private $_writerParts;
@ -61,11 +68,14 @@ class ODText implements IWriter
private $_useDiskCaching = false;
/**
* Disk caching directory
*
* @var string
*/
private $_diskCachingDirectory;
/**
* Create new ODText writer
* @param \PhpOffice\PhpWord\PhpWord $phpWord
*/
public function __construct(PhpWord $phpWord = null)
@ -96,7 +106,7 @@ class ODText implements IWriter
/**
* Save PhpWord to file
*
* @param string $pFileName
* @param string $pFilename
* @throws \PhpOffice\PhpWord\Exceptions\Exception
*/
public function save($pFilename = null)
@ -193,6 +203,8 @@ class ODText implements IWriter
}
/**
* Get PhpWord object
*
* @return \PhpOffice\PhpWord\PhpWord
* @throws \PhpOffice\PhpWord\Exceptions\Exception
*/
@ -206,6 +218,8 @@ class ODText implements IWriter
}
/**
* Set PhpWord object
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return \PhpOffice\PhpWord\Writer\ODText
*/
@ -226,6 +240,8 @@ class ODText implements IWriter
}
/**
* Get writer part
*
* @param string $pPartName Writer part name
* @return \PhpOffice\PhpWord\Writer\ODText\WriterPart
*/
@ -272,6 +288,8 @@ class ODText implements IWriter
}
/**
* Get disk caching directory
*
* @return string
*/
public function getDiskCachingDirectory()

View File

@ -44,6 +44,9 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TOC;
/**
* ODText content part writer
*/
class Content extends WriterPart
{
/**
@ -376,6 +379,8 @@ class Content extends WriterPart
/**
* Write TextBreak
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
protected function _writeTextBreak(XMLWriter $xmlWriter = null)
{
@ -385,10 +390,22 @@ class Content extends WriterPart
}
// @codeCoverageIgnoreStart
/**
* Write end section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null)
{
}
/**
* Write section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null)
{
}

View File

@ -30,6 +30,9 @@ use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\File;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* ODText manifest part writer
*/
class Manifest extends WriterPart
{
/**
@ -120,7 +123,7 @@ class Manifest extends WriterPart
*/
private function _getImageMimeType($pFile = '')
{
if (File::file_exists($pFile)) {
if (File::fileExists($pFile)) {
$image = getimagesize($pFile);
return image_type_to_mime_type($image[2]);
} else {

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* ODText meta part writer
*/
class Meta extends WriterPart
{
/**

View File

@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\PhpWord\PhpWord;
/**
* ODText mimetype part writer
*/
class Mimetype extends WriterPart
{
/**

View File

@ -32,6 +32,9 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull;
/**
* ODText styloes part writer
*/
class Styles extends WriterPart
{
/**

View File

@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Writer\IWriter;
/**
* ODText writer part abstract
*/
abstract class WriterPart
{
/**

View File

@ -45,6 +45,9 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TOC;
/**
* RTF writer
*/
class RTF implements IWriter
{
/**
@ -61,11 +64,29 @@ class RTF implements IWriter
*/
private $_drawingHashTable;
/**
* Color register
*
* @var array
*/
private $_colorTable;
/**
* Font register
*
* @var array
*/
private $_fontTable;
/**
* Last paragraph style
*
* @var mixed
*/
private $_lastParagraphStyle;
/**
* Create new RTF writer
* @param \PhpOffice\PhpWord\PhpWord $phpWord
*/
public function __construct(PhpWord $phpWord = null)
@ -80,7 +101,7 @@ class RTF implements IWriter
/**
* Save PhpWord to file
*
* @param string $pFileName
* @param string $pFilename
* @throws \PhpOffice\PhpWord\Exceptions\Exception
*/
public function save($pFilename = null)
@ -113,6 +134,8 @@ class RTF implements IWriter
}
/**
* Get PhpWord object
*
* @return \PhpOffice\PhpWord\PhpWord
* @throws \PhpOffice\PhpWord\Exceptions\Exception
*/
@ -126,6 +149,8 @@ class RTF implements IWriter
}
/**
* Set PhpWord object
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return \PhpOffice\PhpWord\Writer\RTF
*/
@ -145,6 +170,11 @@ class RTF implements IWriter
return $this->_drawingHashTable;
}
/**
* Get all data
*
* @return string
*/
private function getData()
{
// PhpWord object : $this->_document
@ -198,6 +228,11 @@ class RTF implements IWriter
return $sRTFContent;
}
/**
* Get all fonts
*
* @return array
*/
private function getDataFont()
{
$phpWord = $this->_document;
@ -248,6 +283,11 @@ class RTF implements IWriter
return $arrFonts;
}
/**
* Get all colors
*
* @return array
*/
private function getDataColor()
{
$phpWord = $this->_document;
@ -304,6 +344,11 @@ class RTF implements IWriter
return $arrColors;
}
/**
* Get content data
*
* @return string
*/
private function getDataContent()
{
$phpWord = $this->_document;
@ -350,6 +395,12 @@ class RTF implements IWriter
return $sRTFBody;
}
/**
* Get text element content
*
* @param boolean $withoutP
* @return string
*/
private function getDataContentText(Text $text, $withoutP = false)
{
$sRTFText = '';
@ -438,6 +489,11 @@ class RTF implements IWriter
return $sRTFText;
}
/**
* Get textrun content
*
* @return string
*/
private function getDataContentTextRun(TextRun $textrun)
{
$sRTFText = '';
@ -456,6 +512,11 @@ class RTF implements IWriter
return $sRTFText;
}
/**
* Get text break content
*
* @return string
*/
private function getDataContentTextBreak()
{
$this->_lastParagraphStyle = '';
@ -464,7 +525,7 @@ class RTF implements IWriter
}
/**
* Write unsupported element
* Get unsupported element content
*
* @param string $element
*/

View File

@ -40,15 +40,58 @@ use PhpOffice\PhpWord\Writer\Word2007\Header;
use PhpOffice\PhpWord\Writer\Word2007\Rels;
use PhpOffice\PhpWord\Writer\Word2007\Styles;
/**
* Word2007 writer
*/
class Word2007 implements IWriter
{
/**
* PhpWord object
*
* @var PhpOffice\PhpWord\PhpWord
*/
private $_document;
/**
* Individual writers
*
* @var PhpOffice\PhpWord\Writer\Word2007\WriterPart
*/
private $_writerParts;
/**
* Disk caching directory
*
* @var string
*/
private $_diskCachingDirectory;
/**
* Use disk caching
*
* @var boolean
*/
private $_useDiskCaching = false;
/**
* Types of images
*
* @var array
*/
private $_imageTypes = array();
/**
* Types of objects
*
* @var array
*/
private $_objectTypes = array();
/**
* Create new Word2007 writer
*
* @param PhpOffice\PhpWord\PhpWord
*/
public function __construct(PhpWord $phpWord = null)
{
$this->_document = $phpWord;
@ -71,6 +114,11 @@ class Word2007 implements IWriter
}
}
/**
* Save document by name
*
* @param string $pFilename
*/
public function save($pFilename = null)
{
if (!is_null($this->_document)) {
@ -212,6 +260,8 @@ class Word2007 implements IWriter
}
/**
* Check content types
*
* @param string $src
*/
private function checkContentTypes($src)
@ -251,6 +301,12 @@ class Word2007 implements IWriter
}
}
/**
* Get writer part
*
* @param string $pPartName Writer part name
* @return \PhpOffice\PhpWord\Writer\ODText\WriterPart
*/
public function getWriterPart($pPartName = '')
{
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
@ -260,11 +316,22 @@ class Word2007 implements IWriter
}
}
/**
* Get use disk caching status
*
* @return boolean
*/
public function getUseDiskCaching()
{
return $this->_useDiskCaching;
}
/**
* Set use disk caching status
*
* @param boolean $pValue
* @param string $pDirectory
*/
public function setUseDiskCaching($pValue = false, $pDirectory = null)
{
$this->_useDiskCaching = $pValue;
@ -281,6 +348,8 @@ class Word2007 implements IWriter
}
/**
* Get disk caching directory
*
* @return string
*/
public function getDiskCachingDirectory()
@ -288,6 +357,12 @@ class Word2007 implements IWriter
return $this->_diskCachingDirectory;
}
/**
* Check content types
*
* @param mixed $objZip
* @param mixed $element
*/
private function _addFileToPackage($objZip, $element)
{
if (isset($element['isMemImage']) && $element['isMemImage']) {

View File

@ -44,8 +44,20 @@ use PhpOffice\PhpWord\Style\Cell;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Word2007 base part writer
*
* Write common parts of document.xml, headerx.xml, and footerx.xml
*/
class Base extends WriterPart
{
/**
* Write text element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Text $text
* @param boolean $withoutP
*/
protected function _writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false)
{
$styleFont = $text->getFontStyle();
@ -96,6 +108,12 @@ class Base extends WriterPart
}
}
/**
* Write textrun element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
protected function _writeTextRun(XMLWriter $xmlWriter, TextRun $textrun)
{
$elements = $textrun->getElements();
@ -135,10 +153,11 @@ class Base extends WriterPart
}
/**
* Write paragraph style
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Paragraph $style
* @param bool $withoutPPR
* @return void
*/
protected function _writeParagraphStyle(
XMLWriter $xmlWriter,
@ -236,6 +255,13 @@ class Base extends WriterPart
}
}
/**
* Write link element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Link $link
* @param boolean $withoutP
*/
protected function _writeLink(XMLWriter $xmlWriter, Link $link, $withoutP = false)
{
$rID = $link->getRelationId();
@ -292,6 +318,12 @@ class Base extends WriterPart
}
}
/**
* Write preserve text element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\TextRun $textrun
*/
protected function _writePreserveText(XMLWriter $xmlWriter, PreserveText $textrun)
{
$styleFont = $textrun->getFontStyle();
@ -384,6 +416,12 @@ class Base extends WriterPart
$xmlWriter->endElement(); // p
}
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
protected function _writeTextStyle(XMLWriter $xmlWriter, Font $style)
{
$font = $style->getName();
@ -473,6 +511,8 @@ class Base extends WriterPart
}
/**
* Write text break element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Section\TextBreak $element
*/
@ -519,6 +559,12 @@ class Base extends WriterPart
}
}
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Table $table
*/
protected function _writeTable(XMLWriter $xmlWriter, Table $table)
{
$_rows = $table->getRows();
@ -628,6 +674,12 @@ class Base extends WriterPart
}
}
/**
* Write table style
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Style\Table $style
*/
protected function _writeTableStyle(
XMLWriter $xmlWriter,
\PhpOffice\PhpWord\Style\Table $style = null
@ -675,6 +727,12 @@ class Base extends WriterPart
}
}
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Style\Cell $style
*/
protected function _writeCellStyle(XMLWriter $xmlWriter, Cell $style = null)
{
$bgColor = $style->getBgColor();
@ -779,8 +837,11 @@ class Base extends WriterPart
}
/**
* Write image element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Section\Image|\PhpOffice\PhpWord\Section\MemoryImage $image
* @param mixed $image
* @param boolean $withoutP
*/
protected function _writeImage(XMLWriter $xmlWriter, $image, $withoutP = false)
{
@ -859,6 +920,12 @@ class Base extends WriterPart
}
}
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param mixed $image
*/
protected function _writeWatermark(XMLWriter $xmlWriter, $image)
{
$rId = $image->getRelationId();
@ -903,6 +970,12 @@ class Base extends WriterPart
$xmlWriter->endElement();
}
/**
* Write title element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Title $title
*/
protected function _writeTitle(XMLWriter $xmlWriter, Title $title)
{
$text = htmlspecialchars($title->getText());
@ -945,6 +1018,12 @@ class Base extends WriterPart
$xmlWriter->endElement();
}
/**
* Write footnote element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Footnote $footnote
*/
protected function _writeFootnote(XMLWriter $xmlWriter, Footnote $footnote)
{
$xmlWriter->startElement('w:footnote');
@ -980,6 +1059,13 @@ class Base extends WriterPart
$xmlWriter->endElement(); // w:footnote
}
/**
* Write footnote reference element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Footnote $footnote
* @param boolean $withoutP
*/
protected function _writeFootnoteReference(XMLWriter $xmlWriter, Footnote $footnote, $withoutP = false)
{
if (!$withoutP) {

View File

@ -29,8 +29,18 @@ use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\File;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 contenttypes part writer
*/
class ContentTypes extends WriterPart
{
/**
* Write [Content_Types].xml
* @param array $_imageTypes
* @param array $_objectTypes
* @param int $_cHdrs
* @param array $footers
*/
public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers)
{
// Create XML writer
@ -179,7 +189,7 @@ class ContentTypes extends WriterPart
*/
private function _getImageMimeType($pFile = '')
{
if (File::file_exists($pFile)) {
if (File::fileExists($pFile)) {
$image = getimagesize($pFile);
return image_type_to_mime_type($image[2]);
} else {
@ -188,6 +198,8 @@ class ContentTypes extends WriterPart
}
/**
* Write Default XML element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer
* @param string $pPartname Part name
* @param string $pContentType Content type
@ -207,6 +219,8 @@ class ContentTypes extends WriterPart
}
/**
* Write Override XML element
*
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $pPartname Part name
* @param string $pContentType Content type

View File

@ -28,8 +28,14 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 contenttypes part writer
*/
class DocProps extends WriterPart
{
/**
* Write docProps/app.xml
*/
public function writeDocPropsApp(PhpWord $phpWord = null)
{
// Create XML writer
@ -122,6 +128,11 @@ class DocProps extends WriterPart
}
/**
* Write docProps/core.xml
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeDocPropsCore(PhpWord $phpWord = null)
{
// Create XML writer

View File

@ -44,8 +44,16 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TOC;
/**
* Word2007 document part writer
*/
class Document extends Base
{
/**
* Write word/document.xml
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeDocument(PhpWord $phpWord = null)
{
// Create XML writer
@ -128,6 +136,12 @@ class Document extends Base
return $xmlWriter->getData();
}
/**
* Write begin section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeSection(XMLWriter $xmlWriter, Section $section)
{
$xmlWriter->startElement('w:p');
@ -137,6 +151,12 @@ class Document extends Base
$xmlWriter->endElement();
}
/**
* Write end section
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section $section
*/
private function _writeEndSection(XMLWriter $xmlWriter, Section $section)
{
$settings = $section->getSettings();
@ -270,6 +290,11 @@ class Document extends Base
$xmlWriter->endElement();
}
/**
* Write page break element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function _writePageBreak(XMLWriter $xmlWriter)
{
$xmlWriter->startElement('w:p');
@ -281,6 +306,12 @@ class Document extends Base
$xmlWriter->endElement();
}
/**
* Write list item element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\ListItem $listItem
*/
public function _writeListItem(XMLWriter $xmlWriter, ListItem $listItem)
{
$textObject = $listItem->getTextObject();
@ -320,6 +351,12 @@ class Document extends Base
$xmlWriter->endElement();
}
/**
* Write object element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Section\Object $object
*/
protected function _writeObject(XMLWriter $xmlWriter, Object $object)
{
$rIdObject = $object->getRelationId();
@ -379,6 +416,11 @@ class Document extends Base
$xmlWriter->endElement(); // w:p
}
/**
* Write TOC element
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function _writeTOC(XMLWriter $xmlWriter)
{
$titles = TOC::getTitles();

View File

@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 document rels part writer
*/
class DocumentRels extends WriterPart
{
/**
* Write word/_rels/document.xml.rels
*
* @param array $_relsCollection
*/
public function writeDocumentRels($_relsCollection)
{
// Create XML writer
@ -118,6 +126,11 @@ class DocumentRels extends WriterPart
return $xmlWriter->getData();
}
/**
* Write header footer rels
*
* @param array $_relsCollection
*/
public function writeHeaderFooterRels($_relsCollection)
{
// Create XML writer
@ -156,6 +169,15 @@ class DocumentRels extends WriterPart
return $xmlWriter->getData();
}
/**
* Write individual rels entry
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param int $pId Relationship ID
* @param string $pType Relationship type
* @param string $pTarget Relationship target
* @param string $pTargetMode Relationship target mode
*/
private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
{
if ($pType != '' && $pTarget != '') {

View File

@ -34,8 +34,16 @@ use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 footer part writer
*/
class Footer extends Base
{
/**
* Write word/footnotes.xml
*
* @param PhpOffice\PhpWord\Section\Footer $footer
*/
public function writeFooter(\PhpOffice\PhpWord\Section\Footer $footer)
{
// Create XML writer

View File

@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Section\Footnote;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 footnotes part writer
*/
class Footnotes extends Base
{
/**
* Write word/footnotes.xml
*
* @param array $allFootnotesCollection
*/
public function writeFootnotes($allFootnotesCollection)
{
// Create XML writer

View File

@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 footnotes rel part writer
*/
class FootnotesRels extends WriterPart
{
/**
* Write word/_rels/footnotes.xml.rels
*
* @param mixed $_relsCollection
*/
public function writeFootnotesRels($_relsCollection)
{
// Create XML writer
@ -63,6 +71,15 @@ class FootnotesRels extends WriterPart
return $xmlWriter->getData();
}
/**
* Write individual rels entry
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param int $pId Relationship ID
* @param string $pType Relationship type
* @param string $pTarget Relationship target
* @param string $pTargetMode Relationship target mode
*/
private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
{
if ($pType != '' && $pTarget != '') {

View File

@ -34,8 +34,16 @@ use PhpOffice\PhpWord\Section\TextBreak;
use PhpOffice\PhpWord\Section\TextRun;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 header part writer
*/
class Header extends Base
{
/**
* Write word/headerx.xml
*
* @param PhpOffice\PhpWord\Section\Header $header
*/
public function writeHeader(\PhpOffice\PhpWord\Section\Header $header)
{
// Create XML writer

View File

@ -29,8 +29,16 @@ use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter;
/**
* Word2007 rels part writer
*/
class Rels extends WriterPart
{
/**
* Write _rels/.rels
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeRelationships(PhpWord $phpWord = null)
{
// Create XML writer

View File

@ -32,10 +32,23 @@ use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\Style\TableFull;
/**
* Word2007 styles part writer
*/
class Styles extends Base
{
/**
* PhpWord object
*
* @var PhpWord
*/
private $_document;
/**
* Write word/styles.xml
*
* @param PhpOffice\PhpWord\PhpWord $phpWord
*/
public function writeStyles(PhpWord $phpWord = null)
{
// Create XML writer
@ -184,6 +197,12 @@ class Styles extends Base
return $xmlWriter->getData();
}
/**
* Write table style
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param PhpOffice\PhpWord\Style\TableFull $style
*/
private function _writeFullTableStyle(XMLWriter $xmlWriter, TableFull $style)
{
@ -304,6 +323,13 @@ class Styles extends Base
}
}
/**
* Write first row style
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
* @param string $type
* @param PhpOffice\PhpWord\Style\TableFull $style
*/
private function _writeRowStyle(XMLWriter $xmlWriter, $type, TableFull $style)
{
$brdSz = $style->getBorderSize();
@ -365,6 +391,11 @@ class Styles extends Base
}
/**
* Write document defaults
*
* @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
*/
private function _writeDocDefaults(XMLWriter $xmlWriter)
{
$fontName = $this->_document->getDefaultFontName();

View File

@ -28,15 +28,33 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Exceptions\Exception;
use PhpOffice\PhpWord\Writer\IWriter;
/**
* Word2007 writer part abstract class
*/
abstract class WriterPart
{
/**
* Parent writer
*
* @var IWriter
*/
private $_parentWriter;
/**
* Set parent writer
*
* @param IWriter $pWriter
*/
public function setParentWriter(IWriter $pWriter = null)
{
$this->_parentWriter = $pWriter;
}
/**
* Get parent writer
*
* @return IWriter
*/
public function getParentWriter()
{
if (!is_null($this->_parentWriter)) {

View File

@ -16,7 +16,7 @@ class FileTest extends \PHPUnit_Framework_TestCase
{
$dir = __DIR__ . "/../_files/templates";
chdir($dir);
$this->assertTrue(File::file_exists('blank.docx'));
$this->assertTrue(File::fileExists('blank.docx'));
}
/**
* Test file_exists()
@ -25,7 +25,7 @@ class FileTest extends \PHPUnit_Framework_TestCase
{
$dir = __DIR__ . "/../_files/templates";
chdir($dir);
$this->assertFalse(File::file_exists('404.docx'));
$this->assertFalse(File::fileExists('404.docx'));
}
/**

View File

@ -132,7 +132,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase
$document->cloneRow('userId', 1);
$document->setValue('userId#1', 'Test');
$document->saveAs($docName);
$docFound = file_exists($docName);
$docFound = \file_exists($docName);
unlink($docName);
$this->assertEquals($expectedVar, $actualVar);

View File

@ -74,7 +74,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$writer = new ODText($phpWord);
$writer->save($file);
$this->assertTrue(file_exists($file));
$this->assertTrue(\file_exists($file));
unlink($file);
}

View File

@ -88,7 +88,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
$writer = new RTF($phpWord);
$writer->save($file);
$this->assertTrue(file_exists($file));
$this->assertTrue(\file_exists($file));
unlink($file);
}

View File

@ -66,7 +66,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$writer = new Word2007($phpWord);
$file = __DIR__ . "/../_files/temp.docx";
$writer->save($file);
$this->assertTrue(file_exists($file));
$this->assertTrue(\file_exists($file));
unlink($file);
}

View File

@ -36,7 +36,7 @@ class TestHelperDOCX
public static function clear()
{
if (file_exists(self::$file)) {
if (\file_exists(self::$file)) {
unlink(self::$file);
}
if (is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) {
@ -69,4 +69,4 @@ class TestHelperDOCX
{
return self::$file;
}
}
}

View File

@ -110,4 +110,4 @@ class XmlDocument
$nodeList = $this->getNodeList($path, $file);
return !($nodeList->length == 0);
}
}
}

View File

@ -8,11 +8,11 @@ if (!defined('PHPWORD_TESTS_BASE_DIR')) {
$vendor = realpath(__DIR__ . '/../vendor');
if (file_exists($vendor . "/autoload.php")) {
if (\file_exists($vendor . "/autoload.php")) {
require $vendor . "/autoload.php";
} else {
$vendor = realpath(__DIR__ . '/../../../');
if (file_exists($vendor . "/autoload.php")) {
if (\file_exists($vendor . "/autoload.php")) {
require $vendor . "/autoload.php";
} else {
throw new Exception("Unable to load dependencies");
@ -26,11 +26,11 @@ spl_autoload_register(function ($class) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$class = 'PhpWord' . DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR . '_includes' . substr($class, strlen($prefix));
$file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
if (file_exists($file)) {
if (\file_exists($file)) {
require_once $file;
}
}
});
require_once __DIR__ . "/../src/PhpWord/Autoloader.php";
PhpOffice\PhpWord\Autoloader::register();
PhpOffice\PhpWord\Autoloader::register();