@@ -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'); |
@@ -341,6 +353,9 @@ discard block |
||
| 341 | 353 | return self::loadFileZipSource($tempfile); |
| 342 | 354 | } |
| 343 | 355 | |
| 356 | + /** |
|
| 357 | + * @param string $source |
|
| 358 | + */ |
|
| 344 | 359 | protected static function loadFileZipSource($source) |
| 345 | 360 | { |
| 346 | 361 | $zippy = Zippy::load(); |
@@ -335,9 +335,9 @@ discard block |
||
| 335 | 335 | { |
| 336 | 336 | $tempfile = tempnam(sys_get_temp_dir(), 'datapackage-php'); |
| 337 | 337 | unlink($tempfile); |
| 338 | - $tempfile.='.zip'; |
|
| 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 | return self::loadFileZipSource($tempfile); |
| 342 | 342 | } |
| 343 | 343 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $tempdir = tempnam(sys_get_temp_dir(), 'datapackage-php'); |
| 348 | 348 | unlink($tempdir); |
| 349 | 349 | mkdir($tempdir); |
| 350 | - register_shutdown_function(function() use ($tempdir) {Utils::removeDir($tempdir);}); |
|
| 350 | + register_shutdown_function(function() use ($tempdir) {Utils::removeDir($tempdir); }); |
|
| 351 | 351 | $zippy->open($source)->extract($tempdir); |
| 352 | 352 | if (!file_exists($tempdir."/datapackage.json")) { |
| 353 | 353 | throw new Exceptions\DatapackageInvalidSourceException("zip file must contain a datappackage.json file"); |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | return static::handlesProfile(Registry::getResourceValidationProfile($descriptor)); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function read($readOptions=null) |
|
| 40 | + public function read($readOptions = null) |
|
| 41 | 41 | { |
| 42 | 42 | $limit = ($readOptions && isset($readOptions["limit"])) ? $readOptions["limit"] : null; |
| 43 | 43 | $rows = []; |
@@ -48,7 +48,9 @@ discard block |
||
| 48 | 48 | $rows[] = $row; |
| 49 | 49 | if ($limit !== null) { |
| 50 | 50 | $limit--; |
| 51 | - if ($limit < 0) break; |
|
| 51 | + if ($limit < 0) { |
|
| 52 | + break; |
|
| 53 | + } |
|
| 52 | 54 | } |
| 53 | 55 | }; |
| 54 | 56 | } else { |
@@ -56,11 +58,15 @@ discard block |
||
| 56 | 58 | $rows[] = $row; |
| 57 | 59 | if ($limit !== null) { |
| 58 | 60 | $limit--; |
| 59 | - if ($limit < 0) break; |
|
| 61 | + if ($limit < 0) { |
|
| 62 | + break; |
|
| 63 | + } |
|
| 60 | 64 | } |
| 61 | 65 | } |
| 62 | 66 | } |
| 63 | - if ($limit !== null && $limit < 0) break; |
|
| 67 | + if ($limit !== null && $limit < 0) { |
|
| 68 | + break; |
|
| 69 | + } |
|
| 64 | 70 | } |
| 65 | 71 | return $rows; |
| 66 | 72 | } |