Skip to content

Commit 6c0c8f8

Browse files
committed
analyse code
1 parent 65c155c commit 6c0c8f8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/PhpWord/TemplateProcessor.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -357,19 +357,18 @@ public function setHtmlBlock($search, $htmlContent, $fullHtml = false): void
357357
// Load the XML string into a SimpleXMLElement
358358
$xml = simplexml_load_string($documentXml);
359359
// Extract content between <w:body> tags
360-
if ($xml === false){
360+
if ($xml === false) {
361361
return;
362362
}
363363
$bodyContent = $xml->xpath('//w:body/*');
364364
// Output the extracted content
365365
$documentBodyStr = '';
366366
if ($bodyContent) {
367-
foreach ($bodyContent as $element) {
368-
$documentBodyStr .= $element->asXML();
369-
}
367+
foreach ($bodyContent as $element) {
368+
$documentBodyStr .= $element->asXML();
369+
}
370370
}
371371

372-
373372
//replace html content r:id vaule avoid rid conflict
374373
$rIdsElement = $xml->xpath('//*[@r:id]');
375374
$rIdValuesMap = [];
@@ -390,20 +389,20 @@ public function setHtmlBlock($search, $htmlContent, $fullHtml = false): void
390389
$this->replaceXmlBlock($search, $documentBodyStr, 'w:p');
391390

392391
$xml = simplexml_load_string($relsDocumentXml);
393-
if ($xml === false){
392+
if ($xml === false) {
394393
return;
395394
}
396395
// Register the namespace
397396
$xml->registerXPathNamespace('ns', 'http://schemas.openxmlformats.org/package/2006/relationships');
398397
// Use XPath to find all Relationship nodes
399398
$RelationshipXmls = $xml->xpath('//ns:Relationship');
400399
$RelationshipStr = '';
401-
if ($RelationshipXmls){
400+
if ($RelationshipXmls) {
402401
foreach ($RelationshipXmls as $relationshipXml) {
403402
$rid = (string) $relationshipXml->attributes();
404403
if (isset($rIdValuesMap[$rid])) {
405404
$tmpStr = $relationshipXml->asXML();
406-
if ($tmpStr!=false){
405+
if ($tmpStr != false) {
407406
$tmpStr = str_replace($rid, $rIdValuesMap[$rid], $tmpStr);
408407
$RelationshipStr .= $tmpStr;
409408
}

0 commit comments

Comments
 (0)