Skip to content

Commit 25abccb

Browse files
committed
Replacing DirectoryIterator with FilesystemIterator (again)
This reverts commit a51cfc1.
1 parent 93d433a commit 25abccb

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

examples/run.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
try {
77
$parser = new TextParser(__DIR__ . '/templates');
8-
$textFiles = new DirectoryIterator(__DIR__ . '/test_txt_files');
8+
$textFiles = new FilesystemIterator(__DIR__ . '/test_txt_files');
99

1010
foreach ($textFiles as $txtFileObj) {
11-
if ($txtFileObj->getExtension() == 'txt') {
11+
if ($txtFileObj->getExtension() === 'txt') {
1212
echo $txtFileObj->getFilename() . PHP_EOL;
1313

14-
$parseResults = $parser->parseFileContent($txtFileObj->getPathname());
14+
$parseResults = $parser->parseFileContent($txtFileObj->getPathname(), true);
1515

1616
print_r($parseResults->getParsedRawData());
1717

src/Helper/TemplatesHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class TemplatesHelper
88
{
9-
/** @var \DirectoryIterator; Iterable Directory */
9+
/** @var \FilesystemIterator; Iterable Directory */
1010
private $directoryIterator;
1111

1212

@@ -24,15 +24,15 @@ public function getTemplates(string $text, bool $findMatchingTemplate = false):
2424
return $this->getAllValidTemplates();
2525
}
2626

27-
private function createTemplatesDirIterator(string $iterableDirectoryPath): \DirectoryIterator
27+
private function createTemplatesDirIterator(string $iterableDirectoryPath): \FilesystemIterator
2828
{
2929
if (empty($iterableDirectoryPath) || !is_dir($iterableDirectoryPath)) {
3030
throw new InvalidTemplatesDirectoryException(
3131
'Invalid templates directory provided'
3232
);
3333
}
3434

35-
return new \DirectoryIterator(rtrim($iterableDirectoryPath, '/'));
35+
return new \FilesystemIterator(rtrim($iterableDirectoryPath, '/'));
3636
}
3737

3838
private function findTemplate(string $text): array

0 commit comments

Comments
 (0)