Skip to content

Commit 3a9e585

Browse files
committed
style fixes
1 parent b10287b commit 3a9e585

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

src/DataSources/CsvDataSource.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public function close()
9595
}
9696
}
9797

98-
public function save($outputDataSource) {
98+
public function save($outputDataSource)
99+
{
99100
$file = fopen($outputDataSource, 'w');
100101
fputcsv($file, $this->headerRow);
101102
while (!$this->isEof()) {

src/DataSources/DataSourceInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function open();
2727
public function getNextLine();
2828

2929
/**
30-
* iterate over all rows and save to the given output data source
30+
* iterate over all rows and save to the given output data source.
3131
*
3232
* @param $outputDataSource
3333
*/

src/Table.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ class Table implements \Iterator
1818
*
1919
* @throws Exceptions\DataSourceException
2020
*/
21-
public function __construct($dataSource, $schema=null)
21+
public function __construct($dataSource, $schema = null)
2222
{
23-
if (!is_a($dataSource, "frictionlessdata\\tableschema\\DataSources\\BaseDataSource")) {
23+
if (!is_a($dataSource, 'frictionlessdata\\tableschema\\DataSources\\BaseDataSource')) {
2424
// TODO: more advanced data source detection
2525
$dataSource = new CsvDataSource($dataSource);
2626
}
2727
$this->dataSource = $dataSource;
28-
if (!is_a($schema, "frictionlessdata\\tableschema\\Schema")) {
28+
if (!is_a($schema, 'frictionlessdata\\tableschema\\Schema')) {
2929
if ($schema) {
3030
$schema = new Schema($schema);
3131
} else {
@@ -84,12 +84,14 @@ public static function validate($dataSource, $schema, $numPeekRows = 10)
8484
public function schema($numPeekRows = 10)
8585
{
8686
$this->ensureInferredSchema($numPeekRows);
87+
8788
return $this->schema;
8889
}
8990

9091
public function headers($numPeekRows = 10)
9192
{
9293
$this->ensureInferredSchema($numPeekRows);
94+
9395
return array_keys($this->schema->fields());
9496
}
9597

@@ -99,6 +101,7 @@ public function read()
99101
foreach ($this as $row) {
100102
$rows[] = $row;
101103
}
104+
102105
return $rows;
103106
}
104107

@@ -182,7 +185,7 @@ public function valid()
182185

183186
protected function isInferSchema()
184187
{
185-
return is_a($this->schema, "frictionlessdata\\tableschema\\InferSchema");
188+
return is_a($this->schema, 'frictionlessdata\\tableschema\\InferSchema');
186189
}
187190

188191
protected function ensureInferredSchema($numPeekRows = 10)
@@ -199,6 +202,6 @@ protected function ensureInferredSchema($numPeekRows = 10)
199202
// these rows will be returned by next current() call
200203
$this->castRows = $this->schema->lock();
201204
}
202-
};
205+
}
203206
}
204207
}

tests/TableTest.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ public function testInferSchemaFailsAfterLock()
102102
public function testAutoInferSchemaWhenNullSchema()
103103
{
104104
$table = new Table($this->fixture('data.csv'));
105-
$this->assertTrue(is_a($table->schema(), "frictionlessdata\\tableschema\\InferSchema"));
105+
$this->assertTrue(is_a($table->schema(), 'frictionlessdata\\tableschema\\InferSchema'));
106106
}
107107

108108
public function testHeaders()
109109
{
110110
$table = new Table($this->fixture('data.csv'));
111-
$this->assertEquals(["first_name", "last_name", "order"], $table->headers());
111+
$this->assertEquals(['first_name', 'last_name', 'order'], $table->headers());
112112
$this->assertEquals([
113113
['first_name' => 'Foo', 'last_name' => 'Bar', 'order' => 1],
114114
['first_name' => 'Baz', 'last_name' => 'Bax', 'order' => 2],
115115
['first_name' => 'באך', 'last_name' => 'ביי', 'order' => 3],
116116
], $table->read());
117117

118118
$table = new Table($this->fixture('data.csv'));
119-
$this->assertEquals(["first_name", "last_name", "order"], $table->headers(1));
119+
$this->assertEquals(['first_name', 'last_name', 'order'], $table->headers(1));
120120
$this->assertEquals([
121121
['first_name' => 'Foo', 'last_name' => 'Bar', 'order' => 1],
122122
['first_name' => 'Baz', 'last_name' => 'Bax', 'order' => 2],
@@ -132,12 +132,12 @@ public function testHeaders()
132132
public function testTableSave()
133133
{
134134
$table = new Table($this->fixture('data.csv'));
135-
$table->save("test-table-save-data.csv");
135+
$table->save('test-table-save-data.csv');
136136
$this->assertEquals(
137137
"first_name,last_name,order\nFoo,Bar,1\nBaz,Bax,2\nבאך,ביי,3\n",
138-
file_get_contents("test-table-save-data.csv")
138+
file_get_contents('test-table-save-data.csv')
139139
);
140-
unlink("test-table-save-data.csv");
140+
unlink('test-table-save-data.csv');
141141
}
142142

143143
public function testInferSchemaWorksWithMoreRows()
@@ -160,13 +160,13 @@ public function testInferSchemaWorksWithMoreRows()
160160

161161
public function testSimpleInferSchema()
162162
{
163-
$table = new Table($this->fixture("data.csv"));
164-
$this->assertEquals((object)[
165-
"fields" => [
166-
(object)["name" => "first_name", "type" => "string"],
167-
(object)["name" => "last_name", "type" => "string"],
168-
(object)["name" => "order", "type" => "integer"],
169-
]
163+
$table = new Table($this->fixture('data.csv'));
164+
$this->assertEquals((object) [
165+
'fields' => [
166+
(object) ['name' => 'first_name', 'type' => 'string'],
167+
(object) ['name' => 'last_name', 'type' => 'string'],
168+
(object) ['name' => 'order', 'type' => 'integer'],
169+
],
170170
], $table->schema()->descriptor());
171171
}
172172

0 commit comments

Comments
 (0)