Skip to content

Commit e1164f8

Browse files
author
Roman Syroeshko
committed
[Changed] Refactored Template a little.
1 parent c446028 commit e1164f8

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

src/PhpWord/Template.php

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,28 @@ class Template
3636
private $zipClass;
3737

3838
/**
39-
* Temporary file name
39+
* Temporary file name.
4040
*
4141
* @var string
4242
*/
4343
private $tempFileName;
4444

4545
/**
46-
* Document XML
46+
* Document XML.
4747
*
4848
* @var string
4949
*/
5050
private $documentXML;
5151

5252
/**
53-
* Document header XML
53+
* Document header XML.
5454
*
5555
* @var string[]
5656
*/
5757
private $headerXMLs = array();
5858

5959
/**
60-
* Create a new Template Object
60+
* Create a new Template Object.
6161
*
6262
* @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception.
6363
*
@@ -97,18 +97,19 @@ public function __construct($fileName)
9797
}
9898

9999
/**
100-
* Document footer XML
100+
* Document footer XML.
101101
*
102102
* @var string[]
103103
*/
104104
private $footerXMLs = array();
105105

106106
/**
107-
* Applies XSL style sheet to template's parts
107+
* Applies XSL style sheet to template's parts.
108108
*
109109
* @param \DOMDocument $xslDOMDocument
110110
* @param array $xslOptions
111111
* @param string $xslOptionsURI
112+
* @return void
112113
* @throws \PhpOffice\PhpWord\Exception\Exception
113114
*/
114115
public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xslOptionsURI = '')
@@ -135,11 +136,12 @@ public function applyXslStyleSheet(&$xslDOMDocument, $xslOptions = array(), $xsl
135136
}
136137

137138
/**
138-
* Set a Template value
139+
* Set a Template value.
139140
*
140141
* @param mixed $search
141142
* @param mixed $replace
142143
* @param integer $limit
144+
* @return void
143145
*/
144146
public function setValue($search, $replace, $limit = -1)
145147
{
@@ -155,7 +157,8 @@ public function setValue($search, $replace, $limit = -1)
155157
}
156158

157159
/**
158-
* Returns array of all variables in template
160+
* Returns array of all variables in template.
161+
*
159162
* @return string[]
160163
*/
161164
public function getVariables()
@@ -174,7 +177,7 @@ public function getVariables()
174177
}
175178

176179
/**
177-
* Clone a table row in a template document
180+
* Clone a table row in a template document.
178181
*
179182
* @param string $search
180183
* @param integer $numberOfClones
@@ -230,7 +233,7 @@ public function cloneRow($search, $numberOfClones)
230233
}
231234

232235
/**
233-
* Clone a block
236+
* Clone a block.
234237
*
235238
* @param string $blockname
236239
* @param integer $clones
@@ -266,10 +269,11 @@ public function cloneBlock($blockname, $clones = 1, $replace = true)
266269
}
267270

268271
/**
269-
* Replace a block
272+
* Replace a block.
270273
*
271274
* @param string $blockname
272275
* @param string $replacement
276+
* @return void
273277
*/
274278
public function replaceBlock($blockname, $replacement)
275279
{
@@ -289,17 +293,18 @@ public function replaceBlock($blockname, $replacement)
289293
}
290294

291295
/**
292-
* Delete a block of text
296+
* Delete a block of text.
293297
*
294298
* @param string $blockname
299+
* @return void
295300
*/
296301
public function deleteBlock($blockname)
297302
{
298303
$this->replaceBlock($blockname, '');
299304
}
300305

301306
/**
302-
* Save XML to temporary file
307+
* Save XML to temporary file.
303308
*
304309
* @return string
305310
* @throws \PhpOffice\PhpWord\Exception\Exception
@@ -325,10 +330,12 @@ public function save()
325330
}
326331

327332
/**
328-
* Save XML to defined name
333+
* Save XML to defined name.
329334
*
330-
* @param string $fileName
331335
* @since 0.8.0
336+
*
337+
* @param string $fileName
338+
* @return void
332339
*/
333340
public function saveAs($fileName)
334341
{
@@ -375,7 +382,8 @@ protected function setValueForPart($documentPartXML, $search, $replace, $limit)
375382
}
376383

377384
/**
378-
* Find all variables in $documentPartXML
385+
* Find all variables in $documentPartXML.
386+
*
379387
* @param string $documentPartXML
380388
* @return string[]
381389
*/
@@ -387,7 +395,8 @@ protected function getVariablesForPart($documentPartXML)
387395
}
388396

389397
/**
390-
* Get the name of the footer file for $index
398+
* Get the name of the footer file for $index.
399+
*
391400
* @param integer $index
392401
* @return string
393402
*/
@@ -397,7 +406,8 @@ private function getFooterName($index)
397406
}
398407

399408
/**
400-
* Get the name of the header file for $index
409+
* Get the name of the header file for $index.
410+
*
401411
* @param integer $index
402412
* @return string
403413
*/
@@ -407,7 +417,7 @@ private function getHeaderName($index)
407417
}
408418

409419
/**
410-
* Find the start position of the nearest table row before $offset
420+
* Find the start position of the nearest table row before $offset.
411421
*
412422
* @param integer $offset
413423
* @return integer
@@ -426,7 +436,7 @@ private function findRowStart($offset)
426436
}
427437

428438
/**
429-
* Find the end position of the nearest table row after $offset
439+
* Find the end position of the nearest table row after $offset.
430440
*
431441
* @param integer $offset
432442
* @return integer
@@ -438,7 +448,7 @@ private function findRowEnd($offset)
438448
}
439449

440450
/**
441-
* Get a slice of a string
451+
* Get a slice of a string.
442452
*
443453
* @param integer $startPosition
444454
* @param integer $endPosition

0 commit comments

Comments
 (0)