@@ -229,6 +229,8 @@ discard block |
||
| 229 | 229 | /** |
| 230 | 230 | * allows extending classes to add custom sources |
| 231 | 231 | * used by unit tests to add a mock http source. |
| 232 | + * @param string $source |
|
| 233 | + * @return string |
|
| 232 | 234 | */ |
| 233 | 235 | protected static function normalizeHttpSource($source) |
| 234 | 236 | { |
@@ -238,6 +240,7 @@ discard block |
||
| 238 | 240 | /** |
| 239 | 241 | * allows extending classes to add custom sources |
| 240 | 242 | * used by unit tests to add a mock http source. |
| 243 | + * @param string $source |
|
| 241 | 244 | */ |
| 242 | 245 | protected static function isHttpSource($source) |
| 243 | 246 | { |
@@ -251,7 +254,7 @@ discard block |
||
| 251 | 254 | * - normalized basePath. |
| 252 | 255 | * |
| 253 | 256 | * @param $source |
| 254 | - * @param $basePath |
|
| 257 | + * @param null|string $basePath |
|
| 255 | 258 | * |
| 256 | 259 | * @return object |
| 257 | 260 | * |
@@ -321,16 +324,25 @@ discard block |
||
| 321 | 324 | return (object) ['descriptor' => $descriptor, 'basePath' => $basePath]; |
| 322 | 325 | } |
| 323 | 326 | |
| 327 | + /** |
|
| 328 | + * @param string $source |
|
| 329 | + */ |
|
| 324 | 330 | protected static function isHttpZipSource($source) |
| 325 | 331 | { |
| 326 | 332 | return strtolower(substr($source, -4)) == '.zip'; |
| 327 | 333 | } |
| 328 | 334 | |
| 335 | + /** |
|
| 336 | + * @param string $source |
|
| 337 | + */ |
|
| 329 | 338 | protected static function isFileZipSource($source) |
| 330 | 339 | { |
| 331 | 340 | return strtolower(substr($source, -4)) == '.zip'; |
| 332 | 341 | } |
| 333 | 342 | |
| 343 | + /** |
|
| 344 | + * @param string $source |
|
| 345 | + */ |
|
| 334 | 346 | protected static function loadHttpZipSource($source) |
| 335 | 347 | { |
| 336 | 348 | $tempfile = tempnam(sys_get_temp_dir(), 'datapackage-php'); |
@@ -342,6 +354,9 @@ discard block |
||
| 342 | 354 | return self::loadFileZipSource($tempfile); |
| 343 | 355 | } |
| 344 | 356 | |
| 357 | + /** |
|
| 358 | + * @param string $source |
|
| 359 | + */ |
|
| 345 | 360 | protected static function loadFileZipSource($source) |
| 346 | 361 | { |
| 347 | 362 | $zippy = Zippy::load(); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | unlink($tempfile); |
| 338 | 338 | $tempfile .= '.zip'; |
| 339 | 339 | stream_copy_to_stream(fopen($source, 'r'), fopen($tempfile, 'w')); |
| 340 | - register_shutdown_function(function () use ($tempfile) {unlink($tempfile); }); |
|
| 340 | + register_shutdown_function(function() use ($tempfile) {unlink($tempfile); }); |
|
| 341 | 341 | |
| 342 | 342 | return self::loadFileZipSource($tempfile); |
| 343 | 343 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | $tempdir = tempnam(sys_get_temp_dir(), 'datapackage-php'); |
| 349 | 349 | unlink($tempdir); |
| 350 | 350 | mkdir($tempdir); |
| 351 | - register_shutdown_function(function () use ($tempdir) {Utils::removeDir($tempdir); }); |
|
| 351 | + register_shutdown_function(function() use ($tempdir) {Utils::removeDir($tempdir); }); |
|
| 352 | 352 | $zippy->open($source)->extract($tempdir); |
| 353 | 353 | if (!file_exists($tempdir.'/datapackage.json')) { |
| 354 | 354 | throw new Exceptions\DatapackageInvalidSourceException('zip file must contain a datappackage.json file'); |