public function parseFile($file, $assoc = false, $depth = 512)
    {
        if (false === is_file($file)) {
            throw new InvalidArgumentException(sprintf(
                'The JSON file path "%s" is either not a file or it does not exist.',
                $file
            ));
        }

        if (false === ($contents = @ file_get_contents($file))) {
            $error = error_get_last();

            throw new RuntimeException(sprintf(
                'The JSON file "%s" could not be read: %s',
                $file,
                $error['message']
            ));
        }

        return $this->parse($contents, $assoc, $depth);
    }
public function parseFile($file, $assoc = false, $depth = 512)
    {
        if (false === is_file($file)) {
            throw new InvalidArgumentException(sprintf(
                'The JSON file path "%s" is either not a file or it does not exist.',
                $file
            ));
        }

        if (false === ($contents = @ file_get_contents($file))) {
            $error = error_get_last();

            throw new RuntimeException(sprintf(
                'The JSON file "%s" could not be read: %s',
                $file,
                $error['message']
            ));
        }

        return $this->parse($contents, $assoc, $depth);
    }
public function parseFile ( $ file , $ assoc = false , $ depth = 512 ) { if ( false === is_file ( $ file ) ) { throw new InvalidArgumentException ( sprintf ( 'The JSON file path "%s" is either not a file or it does not exist.' , $ file ) ) ; } if ( false === ( $ contents = @ file_get_contents ( $ file ) ) ) { $ error = error_get_last ( ) ; throw new RuntimeException ( sprintf ( 'The JSON file "%s" could not be read: %s' , $ file , $ error [ 'message' ] ) ) ; } return $ this -> parse ( $ contents , $ assoc , $ depth ) ; }
Parses a JSON file.

@param string  $file  The JSON file.
@param boolean $assoc Convert objects to associate arrays?
@param integer $depth The maximum recursion depth.

@return mixed The parsed data.

@throws InvalidArgumentException If the JSON file does not exist.
@throws RuntimeException         If the JSON file could not be read.

@api
Parses a JSON file .