Skip to content

Commit

Permalink
new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
sibalonat committed Nov 30, 2023
1 parent 41beb2d commit a08da1e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion samples/Sample_44_ExtractVariablesFromReaderWord2007.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
$name = basename(__FILE__, '.php');
$source = __DIR__ . "/resources/{$name}.docx";
echo date('H:i:s'), " Reading contents from `{$source}`", EOL;
$phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source);
$phpWord = \PhpOffice\PhpWord\IOFactory::extractVariables($source);
6 changes: 3 additions & 3 deletions src/PhpWord/IOFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ public static function load($filename, $readerName = 'Word2007')

return $reader->load($filename);
}

/**
* Loads PhpWord ${variable} from file.
*
* @param string $filename The name of the file
* @param string $readerName
* @return array The extracted variables
*
* @return array The extracted variables
*/
public static function extractVariables(string $filename, $readerName = 'Word2007')
{
Expand Down Expand Up @@ -128,6 +128,7 @@ public static function extractVariables(string $filename, $readerName = 'Word200
}
}
}

return $extractedVariables;
}

Expand All @@ -144,5 +145,4 @@ private static function isConcreteClass($class)

return !$reflection->isAbstract() && !$reflection->isInterface();
}

}
1 change: 1 addition & 0 deletions tests/PhpWordTests/IOFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function testExtractVariables(): void
{
$file = __DIR__ . '/_files/templates/extract-variable.docx';
$extractedVariables = IOFactory::extractVariables($file, 'Word2007');

$expectedVariables = ['date', 'A1', 'B1'];
self::assertEquals($expectedVariables, $extractedVariables, 'Extracted variables do not match expected variables.');
}
Expand Down

0 comments on commit a08da1e

Please sign in to comment.