fix coverage

This commit is contained in:
Libor M 2021-01-10 14:06:19 +01:00
parent 7a131d0ae1
commit ea917c28da
29 changed files with 77 additions and 82 deletions

View File

@ -46,6 +46,7 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return round($pValue / 9525); return round($pValue / 9525);
} }
@ -71,7 +72,8 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return ((($pValue * 1.333333333) / self::DPI_96) * 2.54);
return (($pValue * 1.333333333) / self::DPI_96) * 2.54;
} }
/** /**
@ -85,6 +87,7 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return $pValue * 1.333333333; return $pValue * 1.333333333;
} }
@ -97,7 +100,7 @@ class Drawing
public static function pixelsToCentimeters($pValue = 0) public static function pixelsToCentimeters($pValue = 0)
{ {
//return $pValue * 0.028; //return $pValue * 0.028;
return (($pValue / self::DPI_96) * 2.54); return ($pValue / self::DPI_96) * 2.54;
} }
/** /**
@ -111,6 +114,7 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return ($pValue / 2.54) * self::DPI_96; return ($pValue / 2.54) * self::DPI_96;
} }
@ -136,13 +140,14 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return round($pValue / 60000); return round($pValue / 60000);
} }
/** /**
* Convert centimeters width to twips * Convert centimeters width to twips
* *
* @param integer $pValue * @param int $pValue
* @return float * @return float
*/ */
public static function centimetersToTwips($pValue = 0) public static function centimetersToTwips($pValue = 0)
@ -150,13 +155,14 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return $pValue * 566.928; return $pValue * 566.928;
} }
/** /**
* Convert twips width to centimeters * Convert twips width to centimeters
* *
* @param integer $pValue * @param int $pValue
* @return float * @return float
*/ */
public static function twipsToCentimeters($pValue = 0) public static function twipsToCentimeters($pValue = 0)
@ -164,13 +170,14 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return $pValue / 566.928; return $pValue / 566.928;
} }
/** /**
* Convert inches width to twips * Convert inches width to twips
* *
* @param integer $pValue * @param int $pValue
* @return float * @return float
*/ */
public static function inchesToTwips($pValue = 0) public static function inchesToTwips($pValue = 0)
@ -178,13 +185,14 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return $pValue * 1440; return $pValue * 1440;
} }
/** /**
* Convert twips width to inches * Convert twips width to inches
* *
* @param integer $pValue * @param int $pValue
* @return float * @return float
*/ */
public static function twipsToInches($pValue = 0) public static function twipsToInches($pValue = 0)
@ -192,13 +200,14 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return $pValue / 1440; return $pValue / 1440;
} }
/** /**
* Convert twips width to pixels * Convert twips width to pixels
* *
* @param integer $pValue * @param int $pValue
* @return float * @return float
*/ */
public static function twipsToPixels($pValue = 0) public static function twipsToPixels($pValue = 0)
@ -206,6 +215,7 @@ class Drawing
if ($pValue == 0) { if ($pValue == 0) {
return 0; return 0;
} }
return round($pValue / 15.873984); return round($pValue / 15.873984);
} }

View File

@ -69,7 +69,7 @@ class Text
/** /**
* Return a number formatted for being integrated in xml files * Return a number formatted for being integrated in xml files
* @param float $number * @param float $number
* @param integer $decimals * @param int $decimals
* @return string * @return string
*/ */
public static function numberFormat($number, $decimals) public static function numberFormat($number, $decimals)
@ -79,24 +79,25 @@ class Text
/** /**
* @param int $dec * @param int $dec
* @link http://stackoverflow.com/a/7153133/2235790 * @see http://stackoverflow.com/a/7153133/2235790
* @author velcrow * @author velcrow
* @return string * @return string
*/ */
public static function chr($dec) public static function chr($dec)
{ {
if ($dec<=0x7F) { if ($dec <= 0x7F) {
return chr($dec); return chr($dec);
} }
if ($dec<=0x7FF) { if ($dec <= 0x7FF) {
return chr(($dec>>6)+192).chr(($dec&63)+128); return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128);
} }
if ($dec<=0xFFFF) { if ($dec <= 0xFFFF) {
return chr(($dec>>12)+224).chr((($dec>>6)&63)+128).chr(($dec&63)+128); return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
} }
if ($dec<=0x1FFFFF) { if ($dec <= 0x1FFFFF) {
return chr(($dec>>18)+240).chr((($dec>>12)&63)+128).chr((($dec>>6)&63)+128).chr(($dec&63)+128); return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
} }
return ''; return '';
} }
@ -119,7 +120,7 @@ class Text
* Check if a string contains UTF-8 data * Check if a string contains UTF-8 data
* *
* @param string $value * @param string $value
* @return boolean * @return bool
*/ */
public static function isUTF8($value = '') public static function isUTF8($value = '')
{ {
@ -161,7 +162,7 @@ class Text
* @param string $text UTF8 text * @param string $text UTF8 text
* @return array * @return array
* @since 0.11.0 * @since 0.11.0
* @link http://www.randomchaos.com/documents/?source=php_and_unicode * @see http://www.randomchaos.com/documents/?source=php_and_unicode
*/ */
public static function utf8ToUnicode($text) public static function utf8ToUnicode($text)
{ {
@ -201,7 +202,7 @@ class Text
* @param array $unicode * @param array $unicode
* @return string * @return string
* @since 0.11.0 * @since 0.11.0
* @link http://www.randomchaos.com/documents/?source=php_and_unicode * @see http://www.randomchaos.com/documents/?source=php_and_unicode
*/ */
private static function unicodeToEntities($unicode) private static function unicodeToEntities($unicode)
{ {

View File

@ -43,8 +43,8 @@ class XMLReader
* *
* @param string $zipFile * @param string $zipFile
* @param string $xmlFile * @param string $xmlFile
* @return \DOMDocument|false
* @throws \Exception * @throws \Exception
* @return \DOMDocument|false
*/ */
public function getDomFromZip($zipFile, $xmlFile) public function getDomFromZip($zipFile, $xmlFile)
{ {
@ -112,8 +112,8 @@ class XMLReader
* *
* @param string $prefix The prefix * @param string $prefix The prefix
* @param string $namespaceURI The URI of the namespace * @param string $namespaceURI The URI of the namespace
* @return bool true on success or false on failure
* @throws \InvalidArgumentException If called before having loaded the DOM document * @throws \InvalidArgumentException If called before having loaded the DOM document
* @return bool true on success or false on failure
*/ */
public function registerNamespace($prefix, $namespaceURI) public function registerNamespace($prefix, $namespaceURI)
{ {
@ -123,6 +123,7 @@ class XMLReader
if ($this->xpath === null) { if ($this->xpath === null) {
$this->xpath = new \DOMXpath($this->dom); $this->xpath = new \DOMXpath($this->dom);
} }
return $this->xpath->registerNamespace($prefix, $namespaceURI); return $this->xpath->registerNamespace($prefix, $namespaceURI);
} }
@ -192,7 +193,7 @@ class XMLReader
* *
* @param string $path * @param string $path
* @param \DOMElement $contextNode * @param \DOMElement $contextNode
* @return integer * @return int
*/ */
public function countElements($path, \DOMElement $contextNode = null) public function countElements($path, \DOMElement $contextNode = null)
{ {
@ -206,7 +207,7 @@ class XMLReader
* *
* @param string $path * @param string $path
* @param \DOMElement $contextNode * @param \DOMElement $contextNode
* @return boolean * @return bool
*/ */
public function elementExists($path, \DOMElement $contextNode = null) public function elementExists($path, \DOMElement $contextNode = null)
{ {

View File

@ -88,7 +88,7 @@ class XMLWriter extends \XMLWriter
return; return;
} }
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) { if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) {
throw new \Exception('The file '.$this->tempFileName.' could not be deleted.'); throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.');
} }
} }
@ -104,10 +104,10 @@ class XMLWriter extends \XMLWriter
} }
$this->flush(); $this->flush();
return file_get_contents($this->tempFileName); return file_get_contents($this->tempFileName);
} }
/** /**
* Write simple element and attribute(s) block * Write simple element and attribute(s) block
* *
@ -118,7 +118,6 @@ class XMLWriter extends \XMLWriter
* @param string $element * @param string $element
* @param string|array $attributes * @param string|array $attributes
* @param string $value * @param string $value
* @return void
*/ */
public function writeElementBlock($element, $attributes, $value = null) public function writeElementBlock($element, $attributes, $value = null)
{ {
@ -139,7 +138,6 @@ class XMLWriter extends \XMLWriter
* @param string $element * @param string $element
* @param string $attribute * @param string $attribute
* @param mixed $value * @param mixed $value
* @return void
*/ */
public function writeElementIf($condition, $element, $attribute = null, $value = null) public function writeElementIf($condition, $element, $attribute = null, $value = null)
{ {
@ -160,7 +158,6 @@ class XMLWriter extends \XMLWriter
* @param bool $condition * @param bool $condition
* @param string $attribute * @param string $attribute
* @param mixed $value * @param mixed $value
* @return void
*/ */
public function writeAttributeIf($condition, $attribute, $value) public function writeAttributeIf($condition, $attribute, $value)
{ {
@ -179,6 +176,7 @@ class XMLWriter extends \XMLWriter
if (is_float($value)) { if (is_float($value)) {
$value = json_encode($value); $value = json_encode($value);
} }
return parent::writeAttribute($name, $value); return parent::writeAttribute($name, $value);
} }
} }

View File

@ -17,13 +17,13 @@
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Escaper\RegExp; use PhpOffice\PhpWord\Escaper\RegExp;
use PhpOffice\PhpWord\Escaper\Xml; use PhpOffice\PhpWord\Escaper\Xml;
use PhpOffice\PhpWord\Exception\CopyFileException; use PhpOffice\PhpWord\Exception\CopyFileException;
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Shared\Text; use PhpOffice\PhpWord\Shared\Text;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Shared\ZipArchive; use PhpOffice\PhpWord\Shared\ZipArchive;
class TemplateProcessor class TemplateProcessor

View File

@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\ODText\Element; namespace PhpOffice\PhpWord\Writer\ODText\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Row as RowElement; use PhpOffice\PhpWord\Element\Row as RowElement;
use PhpOffice\PhpWord\Element\Table as TableElement; use PhpOffice\PhpWord\Element\Table as TableElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Table element writer * Table element writer

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part; namespace PhpOffice\PhpWord\Writer\ODText\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart as Word2007AbstractPart; use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart as Word2007AbstractPart;

View File

@ -17,7 +17,6 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part; namespace PhpOffice\PhpWord\Writer\ODText\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractContainer; use PhpOffice\PhpWord\Element\AbstractContainer;
use PhpOffice\PhpWord\Element\Field; use PhpOffice\PhpWord\Element\Field;
use PhpOffice\PhpWord\Element\Image; use PhpOffice\PhpWord\Element\Image;
@ -26,6 +25,7 @@ use PhpOffice\PhpWord\Element\Text;
use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange; use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;

View File

@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\ODText\Part; namespace PhpOffice\PhpWord\Writer\ODText\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\Converter; use PhpOffice\PhpWord\Shared\Converter;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style;
/** /**

View File

@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\Text as SharedText; use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Abstract element writer * Abstract element writer

View File

@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement; use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement;
use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Element\AbstractElement as Element;
use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement; use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Container element writer (section, textrun, header, footnote, cell, etc.) * Container element writer (section, textrun, header, footnote, cell, etc.)

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\FormField as FormFieldElement; use PhpOffice\PhpWord\Element\FormField as FormFieldElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* FormField element writer * FormField element writer

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Image as ImageElement; use PhpOffice\PhpWord\Element\Image as ImageElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style\Font as FontStyle;
use PhpOffice\PhpWord\Style\Frame as FrameStyle; use PhpOffice\PhpWord\Style\Frame as FrameStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\SDT as SDTElement; use PhpOffice\PhpWord\Element\SDT as SDTElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Structured document tag element writer * Structured document tag element writer

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Shape as ShapeElement; use PhpOffice\PhpWord\Element\Shape as ShapeElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Shape as ShapeStyle; use PhpOffice\PhpWord\Style\Shape as ShapeStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter;

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\TOC as TOCElement; use PhpOffice\PhpWord\Element\TOC as TOCElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;

View File

@ -17,10 +17,10 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Element; namespace PhpOffice\PhpWord\Writer\Word2007\Element;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Cell as CellElement; use PhpOffice\PhpWord\Element\Cell as CellElement;
use PhpOffice\PhpWord\Element\Row as RowElement; use PhpOffice\PhpWord\Element\Row as RowElement;
use PhpOffice\PhpWord\Element\Table as TableElement; use PhpOffice\PhpWord\Element\Table as TableElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Cell as CellStyle;
use PhpOffice\PhpWord\Style\Row as RowStyle; use PhpOffice\PhpWord\Style\Row as RowStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter;

View File

@ -17,9 +17,9 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\AbstractWriter; use PhpOffice\PhpWord\Writer\AbstractWriter;
/** /**

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Chart as ChartElement; use PhpOffice\PhpWord\Element\Chart as ChartElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Word2007 chart part writer: word/charts/chartx.xml * Word2007 chart part writer: word/charts/chartx.xml

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Comment; use PhpOffice\PhpWord\Element\Comment;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
/** /**

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter;

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Footnote; use PhpOffice\PhpWord\Element\Footnote;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Element\Container;
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Part; namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Word2007 main relationship writer: _rels/.rels * Word2007 main relationship writer: _rels/.rels

View File

@ -17,8 +17,8 @@
namespace PhpOffice\PhpWord\Writer\Word2007\Style; namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\Shared\XMLWriter;
/** /**
* Style writer * Style writer

View File

@ -20,12 +20,10 @@ namespace PhpOffice\PhpWord\Shared;
/** /**
* Test class for PhpOffice\PhpWord\Shared\Drawing * Test class for PhpOffice\PhpWord\Shared\Drawing
* *
* @coversDefaultClass PhpOffice\PhpWord\Shared\Drawing * @coversDefaultClass \PhpOffice\PhpWord\Shared\Drawing
*/ */
class DrawingTest extends \PHPUnit\Framework\TestCase class DrawingTest extends \PHPUnit\Framework\TestCase
{ {
/**
*/
public function testDegreesAngle() public function testDegreesAngle()
{ {
$value = rand(1, 100); $value = rand(1, 100);
@ -36,8 +34,6 @@ class DrawingTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(round($value / 60000), Drawing::angleToDegrees($value)); $this->assertEquals(round($value / 60000), Drawing::angleToDegrees($value));
} }
/**
*/
public function testPixelsCentimeters() public function testPixelsCentimeters()
{ {
$value = rand(1, 100); $value = rand(1, 100);
@ -48,32 +44,26 @@ class DrawingTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($value / 2.54 * Drawing::DPI_96, Drawing::centimetersToPixels($value)); $this->assertEquals($value / 2.54 * Drawing::DPI_96, Drawing::centimetersToPixels($value));
} }
/**
*/
public function testPixelsEMU() public function testPixelsEMU()
{ {
$value = rand(1, 100); $value = rand(1, 100);
$this->assertEquals(0, Drawing::pixelsToEmu()); $this->assertEquals(0, Drawing::pixelsToEmu());
$this->assertEquals(round($value*9525), Drawing::pixelsToEmu($value)); $this->assertEquals(round($value * 9525), Drawing::pixelsToEmu($value));
$this->assertEquals(0, Drawing::emuToPixels()); $this->assertEquals(0, Drawing::emuToPixels());
$this->assertEquals(round($value/9525), Drawing::emuToPixels($value)); $this->assertEquals(round($value / 9525), Drawing::emuToPixels($value));
} }
/**
*/
public function testPixelsPoints() public function testPixelsPoints()
{ {
$value = rand(1, 100); $value = rand(1, 100);
$this->assertEquals(0, Drawing::pixelsToPoints()); $this->assertEquals(0, Drawing::pixelsToPoints());
$this->assertEquals($value*0.67777777, Drawing::pixelsToPoints($value)); $this->assertEquals($value * 0.67777777, Drawing::pixelsToPoints($value));
$this->assertEquals(0, Drawing::pointsToPixels()); $this->assertEquals(0, Drawing::pointsToPixels());
$this->assertEquals($value* 1.333333333, Drawing::pointsToPixels($value)); $this->assertEquals($value * 1.333333333, Drawing::pointsToPixels($value));
} }
/**
*/
public function testPointsCentimeters() public function testPointsCentimeters()
{ {
$value = rand(1, 100); $value = rand(1, 100);
@ -82,8 +72,6 @@ class DrawingTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($value * 1.333333333 / Drawing::DPI_96 * 2.54, Drawing::pointsToCentimeters($value)); $this->assertEquals($value * 1.333333333 / Drawing::DPI_96 * 2.54, Drawing::pointsToCentimeters($value));
} }
/**
*/
public function testTwips() public function testTwips()
{ {
$value = rand(1, 100); $value = rand(1, 100);

View File

@ -20,12 +20,10 @@ namespace PhpOffice\PhpWord\Shared;
/** /**
* Test class for Text * Test class for Text
* *
* @coversDefaultClass PhpOffice\PhpWord\Shared\Text * @coversDefaultClass \PhpOffice\PhpWord\Shared\Text
*/ */
class TextTest extends \PHPUnit\Framework\TestCase class TextTest extends \PHPUnit\Framework\TestCase
{ {
/**
*/
public function testControlCharacters() public function testControlCharacters()
{ {
$this->assertEquals('', Text::controlCharacterPHP2OOXML()); $this->assertEquals('', Text::controlCharacterPHP2OOXML());
@ -33,7 +31,7 @@ class TextTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('àéîöù', Text::controlCharacterPHP2OOXML('àéîöù')); $this->assertEquals('àéîöù', Text::controlCharacterPHP2OOXML('àéîöù'));
$value = rand(0, 8); $value = rand(0, 8);
$this->assertEquals('_x'.sprintf('%04s', strtoupper(dechex($value))).'_', Text::controlCharacterPHP2OOXML(chr($value))); $this->assertEquals('_x' . sprintf('%04s', strtoupper(dechex($value))) . '_', Text::controlCharacterPHP2OOXML(chr($value)));
$this->assertEquals('', Text::controlCharacterOOXML2PHP('')); $this->assertEquals('', Text::controlCharacterOOXML2PHP(''));
$this->assertEquals(chr(0x08), Text::controlCharacterOOXML2PHP('_x0008_')); $this->assertEquals(chr(0x08), Text::controlCharacterOOXML2PHP('_x0008_'));
@ -58,6 +56,7 @@ class TextTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('🌃', Text::chr(0x1F303)); $this->assertEquals('🌃', Text::chr(0x1F303));
$this->assertEquals('', Text::chr(2097152)); $this->assertEquals('', Text::chr(2097152));
} }
/** /**
* Is UTF8 * Is UTF8
*/ */

View File

@ -20,7 +20,7 @@ namespace PhpOffice\PhpWord\Shared;
/** /**
* Test class for XMLReader * Test class for XMLReader
* *
* @coversDefaultClass PhpOffice\PhpWord\Shared\XMLReader * @coversDefaultClass \PhpOffice\PhpWord\Shared\XMLReader
*/ */
class XMLReaderTest extends \PHPUnit\Framework\TestCase class XMLReaderTest extends \PHPUnit\Framework\TestCase
{ {
@ -57,7 +57,7 @@ class XMLReaderTest extends \PHPUnit\Framework\TestCase
/** /**
* Test that read from non existing archive throws exception * Test that read from non existing archive throws exception
* *
* @expectedException Exception * @expectedException \Exception
*/ */
public function testThrowsExceptionOnNonExistingArchive() public function testThrowsExceptionOnNonExistingArchive()
{ {
@ -124,7 +124,7 @@ class XMLReaderTest extends \PHPUnit\Framework\TestCase
/** /**
* Test that xpath fails if custom namespace is not registered * Test that xpath fails if custom namespace is not registered
* *
* @expectedException InvalidArgumentException * @expectedException \InvalidArgumentException
*/ */
public function testShouldThowExceptionIfTryingToRegisterNamespaceBeforeReadingDoc() public function testShouldThowExceptionIfTryingToRegisterNamespaceBeforeReadingDoc()
{ {

View File

@ -24,8 +24,6 @@ namespace PhpOffice\PhpWord\Shared;
*/ */
class XMLWriterTest extends \PHPUnit\Framework\TestCase class XMLWriterTest extends \PHPUnit\Framework\TestCase
{ {
/**
*/
public function testConstruct() public function testConstruct()
{ {
// Memory // Memory
@ -33,14 +31,14 @@ class XMLWriterTest extends \PHPUnit\Framework\TestCase
$object->startElement('element'); $object->startElement('element');
$object->text('AAA'); $object->text('AAA');
$object->endElement(); $object->endElement();
$this->assertEquals('<element>AAA</element>'.chr(10), $object->getData()); $this->assertEquals('<element>AAA</element>' . chr(10), $object->getData());
// Disk // Disk
$object = new XMLWriter(XMLWriter::STORAGE_DISK); $object = new XMLWriter(XMLWriter::STORAGE_DISK);
$object->startElement('element'); $object->startElement('element');
$object->text('BBB'); $object->text('BBB');
$object->endElement(); $object->endElement();
$this->assertEquals('<element>BBB</element>'.chr(10), $object->getData()); $this->assertEquals('<element>BBB</element>' . chr(10), $object->getData());
} }
public function testWriteAttribute() public function testWriteAttribute()

View File

@ -17,11 +17,11 @@
namespace PhpOffice\PhpWord\Writer\Word2007; namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Element\Comment; use PhpOffice\PhpWord\Element\Comment;
use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange; use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\TestHelperDOCX; use PhpOffice\PhpWord\TestHelperDOCX;
/** /**