Phulp\Source::__construct PHP Метод

__construct() публичный Метод

public __construct ( array $dirs, string $pattern = '', boolean $recursive = false )
$dirs array
$pattern string
$recursive boolean
    public function __construct(array $dirs, $pattern = '', $recursive = false)
    {
        if (!count($dirs)) {
            throw new \UnexpectedValueException('There is no item in the array');
        }
        $finder = new Finder();
        if (!$recursive) {
            $finder->depth('== 0');
        }
        if ($pattern) {
            $finder->name($pattern);
        }
        $finder->in($dirs);
        $this->distFiles = new Collection([], DistFile::class);
        /** @var SplFileInfo $file */
        foreach ($finder as $file) {
            if ($file->isDir()) {
                continue;
            }
            $realPath = $file->getRealPath();
            $dsPos = strrpos($realPath, DIRECTORY_SEPARATOR);
            $this->distFiles->add(new DistFile(file_get_contents($realPath), substr($realPath, $dsPos + 1), substr($realPath, 0, $dsPos), trim($file->getRelativePath(), DIRECTORY_SEPARATOR)));
        }
    }