Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
30 | public function addFromString($localname, $contents) |
||
31 | { |
||
32 | $pathData = pathinfo($localname); |
||
33 | |||
34 | $hFile = fopen($this->tmpDir.'/'.$pathData['basename'], "wb"); |
||
35 | fwrite($hFile, $contents); |
||
36 | fclose($hFile); |
||
37 | |||
38 | $res = $this->oPclZip->add($this->tmpDir.'/'.$pathData['basename'], PCLZIP_OPT_REMOVE_PATH, $this->tmpDir, PCLZIP_OPT_ADD_PATH, $pathData['dirname']); |
||
39 | if ($res == 0) { |
||
40 | throw new \Exception("Error zipping files : " . $this->oPclZip->errorInfo(true)); |
||
41 | } |
||
42 | unlink($this->tmpDir.'/'.$pathData['basename']); |
||
43 | return $this; |
||
44 | } |
||
45 | } |
||
46 |