Skip to content

Commit a9c6134

Browse files
committed
fix coverage
1 parent 7a131d0 commit a9c6134

29 files changed

+77
-82
lines changed

src/PhpWord/Shared/Drawing.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public static function emuToPixels($pValue = 0)
4646
if ($pValue == 0) {
4747
return 0;
4848
}
49+
4950
return round($pValue / 9525);
5051
}
5152

@@ -71,9 +72,10 @@ public static function pointsToCentimeters($pValue = 0)
7172
if ($pValue == 0) {
7273
return 0;
7374
}
74-
return ((($pValue * 1.333333333) / self::DPI_96) * 2.54);
75+
76+
return (($pValue * 1.333333333) / self::DPI_96) * 2.54;
7577
}
76-
78+
7779
/**
7880
* Convert points width to pixels
7981
*
@@ -85,6 +87,7 @@ public static function pointsToPixels($pValue = 0)
8587
if ($pValue == 0) {
8688
return 0;
8789
}
90+
8891
return $pValue * 1.333333333;
8992
}
9093

@@ -97,7 +100,7 @@ public static function pointsToPixels($pValue = 0)
97100
public static function pixelsToCentimeters($pValue = 0)
98101
{
99102
//return $pValue * 0.028;
100-
return (($pValue / self::DPI_96) * 2.54);
103+
return ($pValue / self::DPI_96) * 2.54;
101104
}
102105

103106
/**
@@ -111,6 +114,7 @@ public static function centimetersToPixels($pValue = 0)
111114
if ($pValue == 0) {
112115
return 0;
113116
}
117+
114118
return ($pValue / 2.54) * self::DPI_96;
115119
}
116120

@@ -136,76 +140,82 @@ public static function angleToDegrees($pValue = 0)
136140
if ($pValue == 0) {
137141
return 0;
138142
}
143+
139144
return round($pValue / 60000);
140145
}
141146

142147
/**
143148
* Convert centimeters width to twips
144149
*
145-
* @param integer $pValue
150+
* @param int $pValue
146151
* @return float
147152
*/
148153
public static function centimetersToTwips($pValue = 0)
149154
{
150155
if ($pValue == 0) {
151156
return 0;
152157
}
158+
153159
return $pValue * 566.928;
154160
}
155161

156162
/**
157163
* Convert twips width to centimeters
158164
*
159-
* @param integer $pValue
165+
* @param int $pValue
160166
* @return float
161167
*/
162168
public static function twipsToCentimeters($pValue = 0)
163169
{
164170
if ($pValue == 0) {
165171
return 0;
166172
}
173+
167174
return $pValue / 566.928;
168175
}
169176

170177
/**
171178
* Convert inches width to twips
172179
*
173-
* @param integer $pValue
180+
* @param int $pValue
174181
* @return float
175182
*/
176183
public static function inchesToTwips($pValue = 0)
177184
{
178185
if ($pValue == 0) {
179186
return 0;
180187
}
188+
181189
return $pValue * 1440;
182190
}
183191

184192
/**
185193
* Convert twips width to inches
186194
*
187-
* @param integer $pValue
195+
* @param int $pValue
188196
* @return float
189197
*/
190198
public static function twipsToInches($pValue = 0)
191199
{
192200
if ($pValue == 0) {
193201
return 0;
194202
}
203+
195204
return $pValue / 1440;
196205
}
197206

198207
/**
199208
* Convert twips width to pixels
200209
*
201-
* @param integer $pValue
210+
* @param int $pValue
202211
* @return float
203212
*/
204213
public static function twipsToPixels($pValue = 0)
205214
{
206215
if ($pValue == 0) {
207216
return 0;
208217
}
218+
209219
return round($pValue / 15.873984);
210220
}
211221

src/PhpWord/Shared/Text.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ private static function buildControlCharacters()
3636
{
3737
for ($i = 0; $i <= 19; ++$i) {
3838
if ($i != 9 && $i != 10 && $i != 13) {
39-
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
40-
$replace = chr($i);
39+
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
40+
$replace = chr($i);
4141
self::$controlCharacters[$find] = $replace;
4242
}
4343
}
@@ -69,7 +69,7 @@ public static function controlCharacterPHP2OOXML($value = '')
6969
/**
7070
* Return a number formatted for being integrated in xml files
7171
* @param float $number
72-
* @param integer $decimals
72+
* @param int $decimals
7373
* @return string
7474
*/
7575
public static function numberFormat($number, $decimals)
@@ -79,24 +79,25 @@ public static function numberFormat($number, $decimals)
7979

8080
/**
8181
* @param int $dec
82-
* @link http://stackoverflow.com/a/7153133/2235790
82+
* @see http://stackoverflow.com/a/7153133/2235790
8383
* @author velcrow
8484
* @return string
8585
*/
8686
public static function chr($dec)
8787
{
88-
if ($dec<=0x7F) {
88+
if ($dec <= 0x7F) {
8989
return chr($dec);
9090
}
91-
if ($dec<=0x7FF) {
92-
return chr(($dec>>6)+192).chr(($dec&63)+128);
91+
if ($dec <= 0x7FF) {
92+
return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128);
9393
}
94-
if ($dec<=0xFFFF) {
95-
return chr(($dec>>12)+224).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
94+
if ($dec <= 0xFFFF) {
95+
return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
9696
}
97-
if ($dec<=0x1FFFFF) {
98-
return chr(($dec>>18)+240).chr((($dec>>12)&63)+128).chr((($dec>>6)&63)+128).chr(($dec&63)+128);
97+
if ($dec <= 0x1FFFFF) {
98+
return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
9999
}
100+
100101
return '';
101102
}
102103

@@ -119,7 +120,7 @@ public static function controlCharacterOOXML2PHP($value = '')
119120
* Check if a string contains UTF-8 data
120121
*
121122
* @param string $value
122-
* @return boolean
123+
* @return bool
123124
*/
124125
public static function isUTF8($value = '')
125126
{
@@ -161,7 +162,7 @@ public static function toUnicode($text)
161162
* @param string $text UTF8 text
162163
* @return array
163164
* @since 0.11.0
164-
* @link http://www.randomchaos.com/documents/?source=php_and_unicode
165+
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
165166
*/
166167
public static function utf8ToUnicode($text)
167168
{
@@ -201,7 +202,7 @@ public static function utf8ToUnicode($text)
201202
* @param array $unicode
202203
* @return string
203204
* @since 0.11.0
204-
* @link http://www.randomchaos.com/documents/?source=php_and_unicode
205+
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
205206
*/
206207
private static function unicodeToEntities($unicode)
207208
{

src/PhpWord/Shared/XMLReader.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class XMLReader
4343
*
4444
* @param string $zipFile
4545
* @param string $xmlFile
46-
* @return \DOMDocument|false
4746
* @throws \Exception
47+
* @return \DOMDocument|false
4848
*/
4949
public function getDomFromZip($zipFile, $xmlFile)
5050
{
@@ -112,8 +112,8 @@ public function getElements($path, \DOMElement $contextNode = null)
112112
*
113113
* @param string $prefix The prefix
114114
* @param string $namespaceURI The URI of the namespace
115-
* @return bool true on success or false on failure
116115
* @throws \InvalidArgumentException If called before having loaded the DOM document
116+
* @return bool true on success or false on failure
117117
*/
118118
public function registerNamespace($prefix, $namespaceURI)
119119
{
@@ -123,6 +123,7 @@ public function registerNamespace($prefix, $namespaceURI)
123123
if ($this->xpath === null) {
124124
$this->xpath = new \DOMXpath($this->dom);
125125
}
126+
126127
return $this->xpath->registerNamespace($prefix, $namespaceURI);
127128
}
128129

@@ -192,7 +193,7 @@ public function getValue($path, \DOMElement $contextNode = null)
192193
*
193194
* @param string $path
194195
* @param \DOMElement $contextNode
195-
* @return integer
196+
* @return int
196197
*/
197198
public function countElements($path, \DOMElement $contextNode = null)
198199
{
@@ -206,7 +207,7 @@ public function countElements($path, \DOMElement $contextNode = null)
206207
*
207208
* @param string $path
208209
* @param \DOMElement $contextNode
209-
* @return boolean
210+
* @return bool
210211
*/
211212
public function elementExists($path, \DOMElement $contextNode = null)
212213
{

src/PhpWord/Shared/XMLWriter.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function __destruct()
8888
return;
8989
}
9090
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) {
91-
throw new \Exception('The file '.$this->tempFileName.' could not be deleted.');
91+
throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.');
9292
}
9393
}
9494

@@ -104,10 +104,10 @@ public function getData()
104104
}
105105

106106
$this->flush();
107+
107108
return file_get_contents($this->tempFileName);
108109
}
109110

110-
111111
/**
112112
* Write simple element and attribute(s) block
113113
*
@@ -118,7 +118,6 @@ public function getData()
118118
* @param string $element
119119
* @param string|array $attributes
120120
* @param string $value
121-
* @return void
122121
*/
123122
public function writeElementBlock($element, $attributes, $value = null)
124123
{
@@ -139,7 +138,6 @@ public function writeElementBlock($element, $attributes, $value = null)
139138
* @param string $element
140139
* @param string $attribute
141140
* @param mixed $value
142-
* @return void
143141
*/
144142
public function writeElementIf($condition, $element, $attribute = null, $value = null)
145143
{
@@ -160,7 +158,6 @@ public function writeElementIf($condition, $element, $attribute = null, $value =
160158
* @param bool $condition
161159
* @param string $attribute
162160
* @param mixed $value
163-
* @return void
164161
*/
165162
public function writeAttributeIf($condition, $attribute, $value)
166163
{
@@ -179,6 +176,7 @@ public function writeAttribute($name, $value)
179176
if (is_float($value)) {
180177
$value = json_encode($value);
181178
}
179+
182180
return parent::writeAttribute($name, $value);
183181
}
184182
}

src/PhpWord/TemplateProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
namespace PhpOffice\PhpWord;
1919

20-
use PhpOffice\PhpWord\Shared\XMLWriter;
2120
use PhpOffice\PhpWord\Escaper\RegExp;
2221
use PhpOffice\PhpWord\Escaper\Xml;
2322
use PhpOffice\PhpWord\Exception\CopyFileException;
2423
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
2524
use PhpOffice\PhpWord\Exception\Exception;
2625
use PhpOffice\PhpWord\Shared\Text;
26+
use PhpOffice\PhpWord\Shared\XMLWriter;
2727
use PhpOffice\PhpWord\Shared\ZipArchive;
2828

2929
class TemplateProcessor

src/PhpWord/Writer/ODText/Element/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
namespace PhpOffice\PhpWord\Writer\ODText\Element;
1919

20-
use PhpOffice\PhpWord\Shared\XMLWriter;
2120
use PhpOffice\PhpWord\Element\Row as RowElement;
2221
use PhpOffice\PhpWord\Element\Table as TableElement;
22+
use PhpOffice\PhpWord\Shared\XMLWriter;
2323

2424
/**
2525
* Table element writer

src/PhpWord/Writer/ODText/Part/AbstractPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
namespace PhpOffice\PhpWord\Writer\ODText\Part;
1919

20-
use PhpOffice\PhpWord\Shared\XMLWriter;
2120
use PhpOffice\PhpWord\Settings;
21+
use PhpOffice\PhpWord\Shared\XMLWriter;
2222
use PhpOffice\PhpWord\Style;
2323
use PhpOffice\PhpWord\Style\Font;
2424
use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart as Word2007AbstractPart;

src/PhpWord/Writer/ODText/Part/Content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
namespace PhpOffice\PhpWord\Writer\ODText\Part;
1919

20-
use PhpOffice\PhpWord\Shared\XMLWriter;
2120
use PhpOffice\PhpWord\Element\AbstractContainer;
2221
use PhpOffice\PhpWord\Element\Field;
2322
use PhpOffice\PhpWord\Element\Image;
@@ -26,6 +25,7 @@
2625
use PhpOffice\PhpWord\Element\TextRun;
2726
use PhpOffice\PhpWord\Element\TrackChange;
2827
use PhpOffice\PhpWord\PhpWord;
28+
use PhpOffice\PhpWord\Shared\XMLWriter;
2929
use PhpOffice\PhpWord\Style;
3030
use PhpOffice\PhpWord\Style\Font;
3131
use PhpOffice\PhpWord\Style\Paragraph;

src/PhpWord/Writer/ODText/Part/Styles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
namespace PhpOffice\PhpWord\Writer\ODText\Part;
1919

20-
use PhpOffice\PhpWord\Shared\XMLWriter;
2120
use PhpOffice\PhpWord\Settings;
2221
use PhpOffice\PhpWord\Shared\Converter;
22+
use PhpOffice\PhpWord\Shared\XMLWriter;
2323
use PhpOffice\PhpWord\Style;
2424

2525
/**

src/PhpWord/Writer/Word2007/Element/AbstractElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
namespace PhpOffice\PhpWord\Writer\Word2007\Element;
1919

20-
use PhpOffice\PhpWord\Shared\XMLWriter;
2120
use PhpOffice\PhpWord\Element\AbstractElement as Element;
2221
use PhpOffice\PhpWord\Settings;
2322
use PhpOffice\PhpWord\Shared\Text as SharedText;
23+
use PhpOffice\PhpWord\Shared\XMLWriter;
2424

2525
/**
2626
* Abstract element writer

0 commit comments

Comments
 (0)