/** * Add item to collection. * * @param FilesystemContract $directory * @param string $namespace * @param array $collection */ private function addToCollection(FilesystemContract $directory, $namespace = '', $collection) { foreach ($collection as $item) { $fullPath = $directory->rootPath() . DIRECTORY_SEPARATOR . $item['path']; $trimmedPath = ltrim($item['path'], DIRECTORY_SEPARATOR); $trimmedFullPath = ltrim($fullPath, DIRECTORY_SEPARATOR); if ($this->isExcluded($directory, $trimmedPath, $trimmedFullPath)) { continue; } $this->backup->addToCollection(['name' => $item['path'], 'path' => $fullPath], $namespace); } }