/** * Get parent id as an Option * * @return Option */ protected function optGetParentId() { return Match::on(FTry::with(function () { return $this->chart->getParentId($this->id); }))->Monad_FTry_Success(function ($id) { return Option::create($id->flatten()); })->Monad_FTry_Failure(function () { return Option::create(null); })->value(); }
public function testGettingTheParentIdOfAnAccountThatHasAParentWillReturnTheParentId() { $ac1 = new Account($this->sut, new Nominal('9998'), AccountType::ASSET(), new StringType('Asset')); $this->sut->addAccount($ac1); $ac2 = new Account($this->sut, new Nominal('9999'), AccountType::ASSET(), new StringType('Asset-2')); $this->sut->addAccount($ac2, $ac1->getId()); $f = $this->sut->getParentId($ac2->getId()); $b = $f->get(); $this->assertEquals('9998', $this->sut->getParentId($ac2->getId())->get()); }