Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | n/a |
0 / 0 |
|
| Cosray\escape | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| Cosray\env | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray; |
| 6 | |
| 7 | function escape(string $string): string |
| 8 | { |
| 9 | return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8'); |
| 10 | } |
| 11 | |
| 12 | function env(string $key, mixed $default = null): mixed |
| 13 | { |
| 14 | if (array_key_exists($key, $_SERVER)) { |
| 15 | return $_SERVER[$key]; |
| 16 | } |
| 17 | |
| 18 | if (array_key_exists($key, $_ENV)) { |
| 19 | return $_ENV[$key]; |
| 20 | } |
| 21 | |
| 22 | return $default; |
| 23 | } |