Skip to content

Commit 93500b6

Browse files
committed
Allow to create a record without any defualt data
1 parent fb78102 commit 93500b6

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ You can create a Record object from Storage object:
5656

5757
```php
5858
$storage = new Storage();
59-
$record = $storage->record();
59+
$record = $storage->record(); // You also can provide default data, like an array or stdClass
6060
$record->name = 'Henrique Moody';
6161

6262
$storage->users->insert($record);

src/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function getName()
2525
return $this->name;
2626
}
2727

28-
public function record($record)
28+
public function record($record = array())
2929
{
3030
if (! $record instanceof Record) {
3131
$data = (array) $record;

tests/CollectionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ public function testShouldDefineNameOnConstructor()
1515
$this->assertEquals($name, $collection->getName());
1616
}
1717

18+
public function testShouldCreateNewRecord()
19+
{
20+
$collection = new Collection('whatever');
21+
$record = $collection->record();
22+
23+
$this->assertInstanceOf(__NAMESPACE__ . '\\Record', $record);
24+
}
25+
1826
public function testShouldCreateNewRecordFromArray()
1927
{
2028
$collection = new Collection('whatever');

0 commit comments

Comments
 (0)