for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace unreal4u\FileOperations;
/**
* Gets the contents of our previously declared iterator
*/
class FileContentsGetter extends FileSelection
{
protected $output = [];
public function perform(): FileActionInterface
foreach ($this->iterator as $file) {
if (!$file->isDir()) {
$filename = $file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename();
$this->logger->info('Getting contents', ['file' => $filename, 'dry-run' => $this->isTestMode]);
$this->output[$filename] = file_get_contents($filename);
}
return $this;
* Will return the output generated by the perform action
* @return \Generator
public function getOutput(): \Generator
foreach ($this->output as $filename => $result) {
yield $filename => $result;