Skip to content

Commit 21fc5ab

Browse files
committed
More Coverage Tweaks
1 parent 287fbe1 commit 21fc5ab

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

src/PhpWord/Shared/XMLReader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ public function getDomFromZip($zipFile, $xmlFile)
9191
public function getDomFromString($content)
9292
{
9393
if (\PHP_VERSION_ID < 80000) {
94-
$originalLibXMLEntityValue = libxml_disable_entity_loader(true); //* @codeCoverageIgnore
94+
$originalLibXMLEntityValue = libxml_disable_entity_loader(true); // @codeCoverageIgnore
9595
}
9696
$this->dom = new DOMDocument();
9797
$this->dom->loadXML($content);
9898
if (\PHP_VERSION_ID < 80000) {
99-
libxml_disable_entity_loader($originalLibXMLEntityValue); //* @codeCoverageIgnore
99+
libxml_disable_entity_loader($originalLibXMLEntityValue); // @codeCoverageIgnore
100100
}
101101

102102
return $this->dom;

src/PhpWord/TemplateProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ protected function readPartWithRels($fileName)
189189
protected function transformSingleXml($xml, $xsltProcessor)
190190
{
191191
if (\PHP_VERSION_ID < 80000) {
192-
$orignalLibEntityLoader = libxml_disable_entity_loader(true); //* @codeCoverageIgnore
192+
$orignalLibEntityLoader = libxml_disable_entity_loader(true); // @codeCoverageIgnore
193193
}
194194
$domDocument = new DOMDocument();
195195
if (false === $domDocument->loadXML($xml)) {
@@ -201,7 +201,7 @@ protected function transformSingleXml($xml, $xsltProcessor)
201201
throw new Exception('Could not transform the given XML document.');
202202
}
203203
if (\PHP_VERSION_ID < 80000) {
204-
libxml_disable_entity_loader($orignalLibEntityLoader); //* @codeCoverageIgnore
204+
libxml_disable_entity_loader($orignalLibEntityLoader); // @codeCoverageIgnore
205205
}
206206

207207
return $transformedXml;

src/PhpWord/Writer/HTML/Style/Paragraph.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,10 @@ public function write()
5858
// Alignment
5959
$alignment = $style->getAlignment();
6060
if ('' !== $alignment) {
61-
if (array_key_exists($alignment, self::ALIGNMENT_MAP)) {
62-
$textAlign = self::ALIGNMENT_MAP[$alignment];
63-
} elseif (Jc::END === $alignment) {
61+
if (Jc::END === $alignment) {
6462
$textAlign = $style->isBidi() ? 'left' : 'right';
65-
} else { //all others, including Jc::START
66-
$textAlign = $style->isBidi() ? 'right' : 'left';
63+
} else {
64+
$textAlign = self::ALIGNMENT_MAP[$alignment] ?? ($style->isBidi() ? 'right' : 'left');
6765
}
6866

6967
$css['text-align'] = $textAlign;

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ private function writeCellStyle(CellStyle $cell, ?TableStyle $table): string
175175
return $content;
176176
}
177177

178+
const MAP_BORDER_TYPE = [
179+
Border::DOTTED => '\brdrdot',
180+
];
178181
private function writeCellBorder(string $prefix, ?string $borderStyle, int $borderSize, ?string $borderColor): string
179182
{
180183
if ($borderSize == 0) {
@@ -211,17 +214,7 @@ private function writeCellBorder(string $prefix, ?string $borderStyle, int $bord
211214
* \brdremboss Emboss border.
212215
* \brdrengrave Engrave border.
213216
*/
214-
switch ($borderStyle) {
215-
case Border::DOTTED:
216-
$content .= '\brdrdot';
217-
218-
break;
219-
case Border::SINGLE:
220-
default:
221-
$content .= '\brdrs';
222-
223-
break;
224-
}
217+
$content = self::MAP_BORDER_TYPE[$borderStyle] ?? '\brdrs';
225218

226219
// \brdrwN N is the width in twips (1/20 pt) of the pen used to draw the paragraph border line.
227220
// N cannot be greater than 75.

0 commit comments

Comments
 (0)