thephpleague / factory-muffin

Enables the rapid creation of objects for testing
https://factory-muffin.thephpleague.com/
MIT License
531 stars 72 forks source link

loadDirectory hitting dot-hidden directories #414

Closed LostKobrakai closed 8 years ago

LostKobrakai commented 8 years ago

I've added folder sharing to my vm and mac os is automatically creating .AppleDouble directories in each folder. FactoryMuffin is picking up on them, which results in invalid files being loaded. I've updated the regex statement, which filters the files:

    private function loadDirectory($path)
    {
        $directory = new RecursiveDirectoryIterator($path);
        $iterator = new RecursiveIteratorIterator($directory);
        $files = new RegexIterator($iterator, '/^[^\.](?:(?!\/\.).)+?\.php$/i');

        $fm = $this;

        foreach ($files as $file) {
            require $file->getPathName();
        }
    }

Not sure if that's the correct way of going about it.

GrahamCampbell commented 8 years ago

Looks good to me.

GrahamCampbell commented 8 years ago

I've merged your suggestion.