Skip to content

Commit

Permalink
use ZipFileDecompress
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed Aug 29, 2018
1 parent 147340c commit fa51d99
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Ws/Services/BaseSunat.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use Greenter\Validator\ErrorCodeProviderInterface;
use Greenter\Ws\Reader\CdrReaderInterface;
use Greenter\Ws\Reader\DomCdrReader;
use Greenter\Zip\CompressInterface;
use Greenter\Zip\DecompressInterface;
use Greenter\Zip\ZipFileDecompress;
use Greenter\Zip\ZipFly;

/**
Expand All @@ -20,9 +23,14 @@
class BaseSunat
{
/**
* @var ZipFly
* @var CompressInterface
*/
private $zipper;
private $compressor;

/**
* @var DecompressInterface
*/
private $decompressor;

/**
* @var CdrReaderInterface
Expand Down Expand Up @@ -52,7 +60,9 @@ public function setCodeProvider(ErrorCodeProviderInterface $codeProvider)
*/
public function __construct()
{
$this->zipper = new ZipFly();
//TODO: Inject
$this->compressor = new ZipFly();
$this->decompressor = new ZipFileDecompress();
$this->cdrReader = new DomCdrReader();
}

Expand Down Expand Up @@ -114,7 +124,7 @@ protected function getErrorFromFault(\SoapFault $fault)
*/
protected function compress($filename, $xml)
{
return $this->zipper->compress($filename, $xml);
return $this->compressor->compress($filename, $xml);
}

/**
Expand Down Expand Up @@ -148,7 +158,7 @@ private function getXmlResponse($content)
$filter = function ($filename) {
return strtolower($this->getFileExtension($filename)) === 'xml';
};
$files = $this->zipper->decompress($content, $filter);
$files = $this->decompressor->decompress($content, $filter);

return count($files) === 0 ? '' : $files[0]['content'];
}
Expand Down

0 comments on commit fa51d99

Please sign in to comment.