MediaWiki master
Wikimedia\Leximorph\Util\JsonLoader Class Reference

JsonLoader. More...

Public Member Functions

 __construct (private readonly LoggerInterface $logger,)
 Initializes the JsonLoader with a logger.
 
 load (string $filePath, string $context='', bool $allowMissing=false)
 Loads and decodes a JSON file.
 

Detailed Description

JsonLoader.

Provides methods for loading and decoding JSON files with caching.

Since
1.45
Author
Doğu Abaris (abari.nosp@m.s@nu.nosp@m.ll.ne.nosp@m.t)
Note
https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later

Definition at line 20 of file JsonLoader.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Leximorph\Util\JsonLoader::__construct ( private readonly LoggerInterface $logger)

Initializes the JsonLoader with a logger.

Parameters
LoggerInterface$logger
Since
1.45

Definition at line 29 of file JsonLoader.php.

Member Function Documentation

◆ load()

Wikimedia\Leximorph\Util\JsonLoader::load ( string $filePath,
string $context = '',
bool $allowMissing = false )

Loads and decodes a JSON file.

Parameters
string$filePathThe path to the JSON file.
string$contextA short string to include in log messages.
bool$allowMissingIf true, suppress error logging for missing/unreadable files.
Since
1.45
Returns
array<int|string,mixed> The decoded JSON data, or an empty array on error.

Definition at line 44 of file JsonLoader.php.


The documentation for this class was generated from the following file: