for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
namespace Churn\Managers;
use Churn\Collections\FileCollection;
use Churn\Values\Config;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use Churn\Values\File;
use SplFileInfo;
class FileManager
{
/**
* FileManager constructor.
* @param Config $config Configuration Settings.
*/
public function __construct(Config $config)
$this->config = $config;
config
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Recursively finds all files with the .php extension in the provided
* $path and returns list as array.
* @param string $path Path to look for .php files.
* @return FileCollection
public function getPhpFiles(string $path): FileCollection
$directoryIterator = new RecursiveDirectoryIterator($path);
$files = new FileCollection;
foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
if ($file->getExtension() !== 'php') {
continue;
if ($this->fileShouldBeIgnored($file)) {
$files->push(new File(['displayPath' => $file->getPathName(), 'fullPath' => $file->getRealPath()]));
return $files;
* Determines if a file should be ignored.
* @param \SplFileInfo $file File.
* @return boolean
private function fileShouldBeIgnored(SplFileInfo $file): bool
foreach ($this->config->getFilesToIgnore() as $fileToIgnore) {
$fileToIgnore = str_replace('/', '\/', $fileToIgnore);
if (preg_match("/{$fileToIgnore}/", $file->getPathName())) {
return true;
return false;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: