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