/** * {@inheritdoc} */ public function find($id) { try { return $this->unstableRepository->find($id); } catch (\Exception $exception) { return $this->fallbackRepository->find($id); } }
function it_proxies_any_method_to_fallback_repository_if_the_unstable_one_throws_an_exception(ThemeRepositoryInterface $unstableRepository, ThemeRepositoryInterface $fallbackRepository) { $unstableRepository->find(42)->willThrow(\Exception::class); $fallbackRepository->find(42)->willReturn('result'); $this->find(42)->shouldReturn('result'); }