We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a6f474a commit a67f5bdCopy full SHA for a67f5bd
spec/TableWriterSpec.php
@@ -38,4 +38,11 @@ function it_writes_items(Table $table)
38
39
$this->finish();
40
}
41
+
42
+ function it_handles_zero_items(Table $table)
43
+ {
44
+ $table->setHeaders([])->shouldBeCalled();
45
+ $table->render()->shouldBeCalled();
46
+ $this->finish();
47
+ }
48
src/TableWriter.php
@@ -47,7 +47,8 @@ public function writeItem(array $item) {
* {@inheritdoc}
*/
49
public function finish() {
50
- $this->table->setHeaders(array_keys($this->firstItem));
+ $headers = $this->firstItem ? array_keys($this->firstItem) : [];
51
+ $this->table->setHeaders($headers);
52
$this->table->render();
53
54
$this->firstItem = null;
0 commit comments