Backup #797
| ID | 797 |
| Dateipfad | /var/www/dev.campus.systemische-tools.de/src/Infrastructure/Traits/JsonDecodeTrait.php |
| Version | 1 |
| Typ |
modified |
| Größe | 546 B |
| Hash | 5b3dcda005fa80a50bdc0e3604b0a9d7d0fd428be7e91256cc200db5aebfacdc |
| Datum | 2025-12-23 08:06:44 |
| Geändert von | claude-code-hook |
| Grund | Claude Code Pre-Hook Backup vor Edit-Operation |
| Datei existiert |
Ja
|
Dateiinhalt
<?php
namespace Infrastructure\Traits;
/**
* Trait for safe JSON decoding with default empty array.
* Use in non-Controller classes that need JSON parsing.
*/
trait JsonDecodeTrait
{
/**
* Decode JSON string to array with safe defaults.
*
* @return array<mixed>
*/
protected function decodeJsonArray(?string $json): array
{
if ($json === null || $json === '') {
return [];
}
$decoded = json_decode($json, true);
return is_array($decoded) ? $decoded : [];
}
}
Vollständig herunterladen
Aktionen
← Zurück zur Übersicht