Skip to content

Commit

Permalink
removed extract method (not-used)
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed Nov 14, 2017
1 parent 33d566d commit 62010bd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
35 changes: 0 additions & 35 deletions src/Zip/ZipFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,6 @@ public function compress($filename, $content)
return $archive->file();
}

/**
* Retorna el contenido del archivo especificado dentro del zip.
*
* @param string $zipContent
* @param string $fileToExtract
* @return string
*/
public function decompress($zipContent, $fileToExtract)
{
$start = 0;
$max = 10;
while ($max > 0) {
$dat = substr($zipContent, $start, 30);
if (empty($dat)) {
break;
}

$head = unpack(self::UNZIP_FORMAT, $dat);
$filename = substr(substr($zipContent, $start),30, $head['namelen']);
if (empty($filename)) {
break;
}
$count = 30 + $head['namelen'] + $head['exlen'];

if ($filename == $fileToExtract) {
return gzinflate(substr($zipContent, $start + $count, $head['csize']));
}

$start += $count + $head['csize'];
$max--;
}

return '';
}

/**
* Retorna el contenido del primer xml dentro del zip.
*
Expand Down
9 changes: 0 additions & 9 deletions tests/Ws/Zip/ZipFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ public function testCompressFile()
$this->assertNotEmpty($zip);
}

public function testDecompressFile()
{
$zipContent = $this->createZip();
$helper = new ZipFactory();
$content = $helper->decompress($zipContent, 'myFile.xml');

$this->assertEquals(self::DATA_XML, $content);
}

public function testDecompressLastFile()
{
$zipContent = $this->createZip();
Expand Down

0 comments on commit 62010bd

Please sign in to comment.