From f482f2600bfa8c0e7b82c2b3f541544f99ee223f Mon Sep 17 00:00:00 2001 From: simivar Date: Mon, 7 Nov 2022 22:38:19 +0100 Subject: [PATCH] CS Fixer --- src/PhpWord/TemplateProcessor.php | 36 +++++++------------- tests/PhpWordTests/TemplateProcessorTest.php | 13 ++++--- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index f2438338..6f1ba922 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -761,12 +761,6 @@ class TemplateProcessor /** * Delete a table row in a template document. - * - * @param string $search - * - * @return void - * - * @throws \PhpOffice\PhpWord\Exception\Exception */ public function deleteRow(string $search): void { @@ -776,7 +770,7 @@ class TemplateProcessor $tagPos = strpos($this->tempDocumentMainPart, $search); if (!$tagPos) { - throw new Exception(sprintf("Can not delete row %s, template variable not found or variable contains markup.", $search)); + throw new Exception(sprintf('Can not delete row %s, template variable not found or variable contains markup.', $search)); } $tableStart = $this->findTableStart($tagPos); @@ -1151,21 +1145,21 @@ class TemplateProcessor /** * Find the start position of the nearest table before $offset. - * - * @param integer $offset - * - * @return integer - * - * @throws \PhpOffice\PhpWord\Exception\Exception */ protected function findTableStart(int $offset): int { - $rowStart = strrpos($this->tempDocumentMainPart, 'tempDocumentMainPart) - $offset) * -1)); + $rowStart = strrpos( + $this->tempDocumentMainPart, + 'tempDocumentMainPart) - $offset) * -1) + ); if (!$rowStart) { - $rowStart = strrpos($this->tempDocumentMainPart, '', - ((strlen($this->tempDocumentMainPart) - $offset) * -1)); + $rowStart = strrpos( + $this->tempDocumentMainPart, + '', + ((strlen($this->tempDocumentMainPart) - $offset) * -1) + ); } if (!$rowStart) { throw new Exception('Can not find the start position of the table.'); @@ -1175,12 +1169,8 @@ class TemplateProcessor } /** - * Find the end position of the nearest table row after $offset. - * - * @param integer $offset - * - * @return integer - */ + * Find the end position of the nearest table row after $offset. + */ protected function findTableEnd(int $offset): int { return strpos($this->tempDocumentMainPart, '', $offset) + 7; diff --git a/tests/PhpWordTests/TemplateProcessorTest.php b/tests/PhpWordTests/TemplateProcessorTest.php index 61f76528..e57e5bf1 100644 --- a/tests/PhpWordTests/TemplateProcessorTest.php +++ b/tests/PhpWordTests/TemplateProcessorTest.php @@ -183,30 +183,29 @@ final class TemplateProcessorTest extends \PHPUnit\Framework\TestCase } /** - * @covers ::getVariables * @covers ::deleteRow + * @covers ::getVariables * @covers ::saveAs - * @test */ public function testDeleteRow(): void { $templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/delete-row.docx'); - $this->assertEquals( - array('deleteMe', 'deleteMeToo'), + self::assertEquals( + ['deleteMe', 'deleteMeToo'], $templateProcessor->getVariables() ); $docName = 'delete-row-test-result.docx'; $templateProcessor->deleteRow('deleteMe'); - $this->assertEquals( - array(), + self::assertEquals( + [], $templateProcessor->getVariables() ); $templateProcessor->saveAs($docName); $docFound = file_exists($docName); unlink($docName); - $this->assertTrue($docFound); + self::assertTrue($docFound); } /**