44 public function load(
string $filePath,
string $context =
'',
bool $allowMissing =
false ): array {
46 $data = @file_get_contents( $filePath );
47 if ( $data ===
false ) {
48 if ( !$allowMissing ) {
50 'Failed to read file contents for {context} at {filePath}',
52 'filePath' => $filePath,
53 'context' => $context,
61 $decoded = json_decode( $data,
true );
62 if ( !is_array( $decoded ) ) {
64 'Expected an array from {filePath} for {context}, but received invalid data. JSON error: {error}',
66 'filePath' => $filePath,
67 'context' => $context,
68 'error' => json_last_error_msg(),