version 0.8.0
This commit is contained in:
parent
f22007003a
commit
e5ca9ef194
95 changed files with 5601 additions and 4042 deletions
40
app/Support/helpers.php
Normal file
40
app/Support/helpers.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Globale Helfer-Funktionen (I/O + Normalisierung).
|
||||
* Werden vom Kernel früh eingebunden und stehen allen Controllern/Services
|
||||
* im globalen Namespace zur Verfügung (1:1 aus der alten api.php übernommen).
|
||||
*/
|
||||
|
||||
if (!function_exists('respond')) {
|
||||
function respond(array $data, int $status = 200): never
|
||||
{
|
||||
http_response_code($status);
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('input')) {
|
||||
function input(): array
|
||||
{
|
||||
$raw = file_get_contents('php://input') ?: '';
|
||||
$data = json_decode($raw, true);
|
||||
return is_array($data) ? $data : [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('slugCode')) {
|
||||
function slugCode(string $value): string
|
||||
{
|
||||
return substr(preg_replace('/[^A-Z0-9]/', '', strtoupper($value)) ?? '', 0, 12);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('playerKey')) {
|
||||
function playerKey(string $name): string
|
||||
{
|
||||
return substr(preg_replace('/[^a-z0-9]/', '_', strtolower($name)) ?? '', 0, 40);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue