/** * @param File[] $files * @param string $compressTo * * @return string */ private function createCommand($files, $compressTo) { $baseFolder = $this->deepestCommonFolderHelper->findDeepest($files); $filesToCompress = []; foreach ($files as $file) { $filePathFromBaseFolder = substr($file->getPath(), strlen($baseFolder) + 1); $filesToCompress[] = escapeshellarg($filePathFromBaseFolder); } $filesToCompressInline = implode(' ', $filesToCompress); return $this->compressCommand($compressTo, $baseFolder, $filesToCompressInline); }
/** @test */ public function testFolderEndsWithoutDash() { $deepestFolder = $this->helper->findDeepest([new File('/folder-1/folder-2/file1.txt')]); $this->assertNotEquals('/', substr($deepestFolder, -1)); }