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