Conditions | 6 |
Paths | 5 |
Total Lines | 27 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | 6 | protected function readSourceToLocalFile(string $sourcePath, $sourceData, string $targetLocalFile): void |
|
24 | { |
||
25 | 6 | if ((false === $sourceData) || (null === $sourceData)) { |
|
26 | 2 | throw new MimeException($this->getMiLang()->miCannotLoadFile($sourcePath)); |
|
27 | } |
||
28 | |||
29 | 4 | $stream = fopen($targetLocalFile, 'rb+'); |
|
30 | 4 | if (false === $stream) { |
|
31 | // @codeCoverageIgnoreStart |
||
32 | throw new MimeException($this->getMiLang()->miCannotLoadTempFile()); |
||
33 | } |
||
34 | // @codeCoverageIgnoreEnd |
||
35 | |||
36 | 4 | if (is_resource($sourceData)) { |
|
37 | 1 | rewind($sourceData); |
|
38 | 1 | if (false === stream_copy_to_stream($sourceData, $stream, -1, 0)) { |
|
39 | // @codeCoverageIgnoreStart |
||
40 | throw new MimeException($this->getMiLang()->miCannotGetFilePart($sourcePath)); |
||
41 | } |
||
42 | // @codeCoverageIgnoreEnd |
||
43 | |||
44 | 1 | rewind($stream); |
|
45 | 1 | fclose($stream); |
|
46 | |||
47 | } else { |
||
48 | 3 | fwrite($stream, strval($sourceData)); |
|
49 | 3 | fclose($stream); |
|
50 | } |
||
53 |