RegexIteratorFactory.php 673 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Utility;
  7. /**
  8. * Factory for \RegexIterator
  9. */
  10. class RegexIteratorFactory
  11. {
  12. /**
  13. * Create instance of \RegexIterator
  14. *
  15. * @param string $directoryPath
  16. * @param string $regexp
  17. * @return \RegexIterator
  18. */
  19. public function create($directoryPath, $regexp)
  20. {
  21. $directory = new \RecursiveDirectoryIterator($directoryPath);
  22. $recursiveIterator = new \RecursiveIteratorIterator($directory);
  23. return new \RegexIterator($recursiveIterator, $regexp, \RegexIterator::GET_MATCH);
  24. }
  25. }