src/JsonQueriable.php
protected function getDataFromFile($file, $type = 'application/json')
    {
        if (file_exists($file)) {
            $opts = [
                'http' => [
                    'header' => 'Content-Type: '.$type.'; charset=utf-8',
                ],
            ];

            $context = stream_context_create($opts);
            $data = file_get_contents($file, 0, $context);
            $json = $this->isJson($data, true);
            
            if (!$json) {
                throw new InvalidJsonException();
            }
            
            return $json;
        }

        throw new FileNotFoundException();
    }
protected function getDataFromFile($file, $type = 'application/json')
    {
        if (file_exists($file)) {
            $opts = [
                'http' => [
                    'header' => 'Content-Type: '.$type.'; charset=utf-8',
                ],
            ];

            $context = stream_context_create($opts);
            $data = file_get_contents($file, 0, $context);
            $json = $this->isJson($data, true);
            
            if (!$json) {
                throw new InvalidJsonException();
            }
            
            return $json;
        }

        throw new FileNotFoundException();
    }
protected function getDataFromFile ( $ file , $ type = 'application/json' ) { if ( file_exists ( $ file ) ) { $ opts = [ 'http' => [ 'header' => 'Content-Type: ' . $ type . '; charset=utf-8' , ] , ] ; $ context = stream_context_create ( $ opts ) ; $ data = file_get_contents ( $ file , 0 , $ context ) ; $ json = $ this -> isJson ( $ data , true ) ; if ( ! $ json ) { throw new InvalidJsonException ( ) ; } return $ json ; } throw new FileNotFoundException ( ) ; }
Read JSON data from file

@param string $file
@param string $type
@return bool|string|array
@throws FileNotFoundException
@throws InvalidJsonException
Read JSON data from file