src/Json.php
public function decodeFile($file, $assoc = true, $depth = 512, $options = 0)
    {
        set_error_handler(
                create_function(
                        '$severity, $message, $file, $line', 'throw new ErrorException($message, $severity, $severity, $file, $line);'
                )
        );
        
        try
        {
            $jsonData = file_get_contents($file);
        }
        catch (Exception $e)
        {
            throw new RuntimeException(sprintf($e->getMessage()));
        }

        restore_error_handler();
        
        if(false === $jsonData)
        {
            throw new RuntimeException(sprintf('Unable to get file %s', $file));
        }
        
        return $this->decode($jsonData, $assoc, $depth, $options);
    }
public function decodeFile($file, $assoc = true, $depth = 512, $options = 0)
    {
        set_error_handler(
                create_function(
                        '$severity, $message, $file, $line', 'throw new ErrorException($message, $severity, $severity, $file, $line);'
                )
        );
        
        try
        {
            $jsonData = file_get_contents($file);
        }
        catch (Exception $e)
        {
            throw new RuntimeException(sprintf($e->getMessage()));
        }

        restore_error_handler();
        
        if(false === $jsonData)
        {
            throw new RuntimeException(sprintf('Unable to get file %s', $file));
        }
        
        return $this->decode($jsonData, $assoc, $depth, $options);
    }
public function decodeFile ( $ file , $ assoc = true , $ depth = 512 , $ options = 0 ) { set_error_handler ( create_function ( '$severity, $message, $file, $line' , 'throw new ErrorException($message, $severity, $severity, $file, $line);' ) ) ; try { $ jsonData = file_get_contents ( $ file ) ; } catch ( Exception $ e ) { throw new RuntimeException ( sprintf ( $ e -> getMessage ( ) ) ) ; } restore_error_handler ( ) ; if ( false === $ jsonData ) { throw new RuntimeException ( sprintf ( 'Unable to get file %s' , $ file ) ) ; } return $ this -> decode ( $ jsonData , $ assoc , $ depth , $ options ) ; }
Decode JSON data encoded in file

@param string $file
@param boolean $assoc
@param integer $depth
@param integer $options
@return mixed
@throws RuntimeException
Decode JSON data encoded in file