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