Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Jul 26, 2021
1 parent 45b9730 commit d002a34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Transformers/DataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ protected function resolvePropertyValue(
array $nestedInclusionTree,
array $nestedExclusionTree,
): mixed {
if($value === null){
return null;
}

if ($value instanceof Lazy) {
$value = $value->resolve();
}
Expand Down
15 changes: 15 additions & 0 deletions tests/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@ public function __construct(
$this->assertEquals(['date' => '16-05-1994'], $data->toArray());
}

/** @test */
public function a_transformer_will_never_handle_a_null_value()
{
$data = new class(null) extends Data {
public function __construct(
#[WithTransformer(DateTransformer::class, 'd-m-Y')]
public $date
)
{
}
};

$this->assertEquals(['date' => null], $data->toArray());
}

/** @test */
public function it_can_dynamically_include_data_based_upon_the_request()
{
Expand Down

0 comments on commit d002a34

Please sign in to comment.