Skip to content

Commit 8f0bf49

Browse files
authored
Merge pull request #11 from tattersoftware/attribute-null
Allow null attribute values
2 parents f602add + f2a5593 commit 8f0bf49

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Traits/EntityTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __get(string $key)
1616
// First check the framework's version
1717
$result = parent::__get($key);
1818

19-
if ($result !== null)
19+
if ($result !== null || array_key_exists($key, $this->attributes))
2020
{
2121
return $result;
2222
}

tests/entity/MagicTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ public function testGetIgnoresUnmatched()
2323
{
2424
$this->assertNull($this->factory->racecars);
2525
}
26+
27+
public function testGetRespectsNull()
28+
{
29+
$machine = new Machine([
30+
'factory_id' => 1,
31+
'factory' => null,
32+
]);
33+
34+
$result = $machine->factory;
35+
36+
$this->assertNull($result);
37+
}
2638

2739
public function testRequiresProperties()
2840
{

0 commit comments

Comments
 (0)