Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 9 |
| SystemProxy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
30.00 | |
0.00% |
0 / 9 |
| sendHttpHeader | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| __call | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 4 |
|||
| <?php | |
| namespace Luxian\Common; | |
| use RuntimeException; | |
| /** | |
| * Proxy calls to native PHP functions that cannot be tested | |
| * | |
| * @method ob_start() | |
| * @method ob_get_clean() | |
| * @method phpinfo() | |
| */ | |
| class SystemProxy | |
| { | |
| /** | |
| * Set http headers | |
| * | |
| * @param string $header | |
| * @param bool $replace | |
| * @param int $http_response_code | |
| * | |
| * @SuppressWarnings(PHPMD.BooleanArgumentFlag) | |
| */ | |
| public function sendHttpHeader( | |
| string $header, | |
| bool $replace = true, | |
| int $http_response_code = 0 | |
| ): void | |
| { | |
| if ($http_response_code === 0) { | |
| header($header, $replace); | |
| return; | |
| } | |
| header($header, $replace, $http_response_code); | |
| } | |
| public function __call(string $name, array $arguments) | |
| { | |
| if (function_exists($name) && is_callable($name)) { | |
| return call_user_func_array($name, $arguments); | |
| } | |
| $message = sprintf('Calling undefined function "%s"', $name); | |
| throw new RuntimeException($message); | |
| } | |
| } |