for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Konfig
*
* Yet another simple configuration loader library.
* @author Xeriab Nabil (aka KodeBurner) <[email protected]>
* @license https://raw.github.com/xeriab/konfig/master/LICENSE MIT
* @link https://xeriab.github.io/projects/konfig
*/
namespace Exen\Konfig\FileParser;
use Exen\Konfig\Exception\ParseException;
class Json extends AbstractFileParser
{
* {@inheritDoc}
* Loads a JSON file as an array
* @throws ParseException If there is an error parsing JSON file
* @since 0.1
public function parse($path)
$data = json_decode(file_get_contents($path), true);
if (function_exists('json_last_error_msg')) {
$error_message = json_last_error_msg();
} else {
$error_message = 'Syntax error';
}
if (json_last_error() !== JSON_ERROR_NONE) {
throw new ParseException([
'message' => $error_message,
'type' => json_last_error(),
'file' => $path,
]);
return $data;
public function getSupportedFileExtensions()
return ['json'];
#: END OF ./src/FileParser/Json.php FILE