schnittstabil/json-decode-file

View on GitHub
src/functions.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Schnittstabil\JsonDecodeFile;

use KHerGe\File\Exception\ResourceException;
use Seld\JsonLint\ParsingException;

if (!function_exists('Schnittstabil\JsonDecodeFile\jsonDecodeFile')) {
    /**
     * Read and decode a JSON file.
     *
     * @see http://php.net/manual/en/function.json-decode.php json_decode documentation
     *
     * @param string $path  the file path
     * @param bool   $assoc returned objects will be converted into associative arrays
     *
     * @return mixed the value encoded in json in appropriate PHP type
     *
     * @throws ResourceException
     * @throws ParsingException
     *
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
     * @SuppressWarnings(PHPMD.StaticAccess)
     */
    function jsonDecodeFile($path, $assoc = false)
    {
        return JsonDecodeFile::call($path, $assoc);
    }
}