Skip to content

Commit 0c3e92b

Browse files
committed
style fix
1 parent bf82143 commit 0c3e92b

4 files changed

Lines changed: 33 additions & 24 deletions

File tree

src/Factory.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Factory
2424
* - JSON encoded object
2525
* - URL (must be in either 'http' or 'https' schemes)
2626
* - local filesystem (POSIX) path.
27-
* - local or remote zip file
27+
* - local or remote zip file.
2828
*
2929
* @param mixed $source
3030
* @param null|string $basePath optional, required only if you want to use relative paths
@@ -323,21 +323,22 @@ protected static function loadSource($source, $basePath)
323323

324324
protected static function isHttpZipSource($source)
325325
{
326-
return (strtolower(substr($source, -4)) == '.zip');
326+
return strtolower(substr($source, -4)) == '.zip';
327327
}
328328

329329
protected static function isFileZipSource($source)
330330
{
331-
return (strtolower(substr($source, -4)) == '.zip');
331+
return strtolower(substr($source, -4)) == '.zip';
332332
}
333333

334334
protected static function loadHttpZipSource($source)
335335
{
336336
$tempfile = tempnam(sys_get_temp_dir(), 'datapackage-php');
337337
unlink($tempfile);
338-
$tempfile.='.zip';
338+
$tempfile .= '.zip';
339339
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+
341342
return self::loadFileZipSource($tempfile);
342343
}
343344

@@ -347,11 +348,12 @@ protected static function loadFileZipSource($source)
347348
$tempdir = tempnam(sys_get_temp_dir(), 'datapackage-php');
348349
unlink($tempdir);
349350
mkdir($tempdir);
350-
register_shutdown_function(function() use ($tempdir) {Utils::removeDir($tempdir);});
351+
register_shutdown_function(function () use ($tempdir) {Utils::removeDir($tempdir); });
351352
$zippy->open($source)->extract($tempdir);
352-
if (!file_exists($tempdir."/datapackage.json")) {
353-
throw new Exceptions\DatapackageInvalidSourceException("zip file must contain a datappackage.json file");
353+
if (!file_exists($tempdir.'/datapackage.json')) {
354+
throw new Exceptions\DatapackageInvalidSourceException('zip file must contain a datappackage.json file');
354355
}
355-
return static::loadSource($tempdir."/datapackage.json", $tempdir);
356+
357+
return static::loadSource($tempdir.'/datapackage.json', $tempdir);
356358
}
357359
}

src/Resources/BaseResource.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,38 @@ public static function handlesDescriptor($descriptor)
3737
return static::handlesProfile(Registry::getResourceValidationProfile($descriptor));
3838
}
3939

40-
public function read($readOptions=null)
40+
public function read($readOptions = null)
4141
{
42-
$limit = ($readOptions && isset($readOptions["limit"])) ? $readOptions["limit"] : null;
42+
$limit = ($readOptions && isset($readOptions['limit'])) ? $readOptions['limit'] : null;
4343
$rows = [];
4444
foreach ($this->dataStreams() as $dataStream) {
4545
if (isset($dataStream->table)) {
46-
$readOptions["limit"] = $limit;
46+
$readOptions['limit'] = $limit;
4747
foreach ($dataStream->table->read($readOptions) as $row) {
4848
$rows[] = $row;
4949
if ($limit !== null) {
50-
$limit--;
51-
if ($limit < 0) break;
50+
--$limit;
51+
if ($limit < 0) {
52+
break;
53+
}
5254
}
53-
};
55+
}
5456
} else {
5557
foreach ($dataStream as $row) {
5658
$rows[] = $row;
5759
if ($limit !== null) {
58-
$limit--;
59-
if ($limit < 0) break;
60+
--$limit;
61+
if ($limit < 0) {
62+
break;
63+
}
6064
}
6165
}
6266
}
63-
if ($limit !== null && $limit < 0) break;
67+
if ($limit !== null && $limit < 0) {
68+
break;
69+
}
6470
}
71+
6572
return $rows;
6673
}
6774

src/Resources/TabularResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ protected function getInlineDataStream($data)
4444

4545
public static function handlesDescriptor($descriptor)
4646
{
47-
return (
47+
return
4848
Registry::getResourceValidationProfile($descriptor) == 'tabular-data-resource'
4949
|| (isset($descriptor->format) && in_array($descriptor->format, ['csv', 'tsv']))
50-
);
50+
;
5151
}
5252
}

tests/DatapackageTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,13 @@ public function testLoadDatapackageZip()
476476
'jurisdiction' => 'Austria',
477477
'population in millions' => 8.7474000000000007,
478478
'GDP in $Billions' => 386.42779999999999,
479-
'GDP per cap' => 44176.519999999997
479+
'GDP per cap' => 44176.519999999997,
480480
], [
481481
'jurisdiction' => 'Belgium',
482482
'population in millions' => 11.3482,
483483
'GDP in $Billions' => 466.3657,
484-
'GDP per cap' => 41096.160000000003
485-
]], $package->resource('eucountrydatawb_csv')->read(["limit" => 2]));
484+
'GDP per cap' => 41096.160000000003,
485+
]], $package->resource('eucountrydatawb_csv')->read(['limit' => 2]));
486486
}
487487

488488
public function testStringPath()
@@ -557,7 +557,7 @@ public function testDataHubCountryList()
557557
}
558558
}
559559
$this->assertEquals(['data_csv', 'data_json', 'datapackage_zip', 'data'], array_keys($resources));
560-
$this->assertEquals(["Name" => "Afghanistan", "Code" => "AF"], $resources['data_csv'][0]);
560+
$this->assertEquals(['Name' => 'Afghanistan', 'Code' => 'AF'], $resources['data_csv'][0]);
561561

562562
// now, let's try to load it but get it as tabular data
563563
$descriptor = json_decode(file_get_contents(dirname(__FILE__).'/fixtures/datahub-country-list/datapackage.json'));

0 commit comments

Comments
 (0)