Skip to content

Commit

Permalink
Merge 0e7a6e6 into ec06573
Browse files Browse the repository at this point in the history
  • Loading branch information
gong023 committed Sep 9, 2016
2 parents ec06573 + 0e7a6e6 commit ee1eaac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/ReadableAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ private function mayHaveAsBooleanArray()
return $this->attributes->mayHave($propertyName)->asBooleanArray();
}

private function getValue()
{
static $propertyName;
if ($propertyName === null) {
$propertyName = $this->calledPropertyName();
}

return $this->attributes->mayHave($propertyName)->value();
}

public function toArray()
{
$array = [];
Expand Down
1 change: 1 addition & 0 deletions tests/Example/ObjectWithOptionalValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ class ObjectWithOptionalValues
mayHaveAsFloatArray as public getPointOneArray;
mayHaveAsStringArray as public getStringArray;
mayHaveAsBooleanArray as public getTrueArray;
getValue as public getNull;
}
}
6 changes: 4 additions & 2 deletions tests/OptionalCastedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public function testCasted()
'one_array' => ['1', '2', '3'],
'point_one_array' => ['0.1', '0.2', '0.3'],
'string_array' => [1, 2, 3],
'true_array' => ['true', 'true', 'true']
'true_array' => ['true', 'true', 'true'],
'null_value' => null,
]);

$this->assert()
Expand All @@ -32,7 +33,8 @@ public function testCasted()
->same([1, 2, 3], $optional->getOneArray())
->same([0.1, 0.2, 0.3], $optional->getPointOneArray())
->same(['1', '2', '3'], $optional->getStringArray())
->same([true, true, true], $optional->getTrueArray());
->same([true, true, true], $optional->getTrueArray())
->null($optional->getNull());
}

public function testCastedWithUndefined()
Expand Down

0 comments on commit ee1eaac

Please sign in to comment.