public function __get($field) { if (!property_exists($this->object, $field)) { return Optional::absent(); } return Optional::fromNullable($this->object->{$field}); }
/** * @return Node|null */ public function getReturnNode() { return Optional::fromNullable($this->return)->getNode()->or(null); }
/** * @test */ public function shouldFlattenNullValue() { //given $optional = Optional::of(Optional::of(Optional::fromNullable(null))); //when $result = $optional->flatten()->orNull(); //then Assert::that($result)->isNull(); }