Validate URLs; check for file/json read errors.
This commit is contained in:
parent
d85c25bdb3
commit
4ddb4e8c2c
2 changed files with 21 additions and 4 deletions
14
test.php
14
test.php
|
@ -570,15 +570,23 @@ class EarlReport implements PHPUnit_Framework_TestListener {
|
|||
|
||||
class Util {
|
||||
public static function readFile($filename) {
|
||||
return file_get_contents($filename);
|
||||
$rval = @file_get_contents($filename);
|
||||
if($rval === false) {
|
||||
throw new Exception('File read error: ' . $filename);
|
||||
}
|
||||
return $rval;
|
||||
}
|
||||
|
||||
public static function readJson($filename) {
|
||||
return json_decode(file_get_contents($filename));
|
||||
$rval = json_decode(self::readFile($filename));
|
||||
if($rval === null) {
|
||||
throw new Exception('JSON parse error');
|
||||
}
|
||||
return $rval;
|
||||
}
|
||||
|
||||
public static function readNQuads($filename) {
|
||||
return readFile($filename);
|
||||
return self::readFile($filename);
|
||||
}
|
||||
|
||||
public static function jsonldEncode($input) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue