Support the ongoing development of Laravel.io →
Configuration Architecture
Last updated 2 years ago.
0

It sounds like it's not 100% related to dependency injection. I feel like you're looking for a chain of responsibility pattern.

Try http://dsheiko.com/subpage/chain-of-responsibility-pattern

Last updated 2 years ago.
0

That was quick and is what I'm looking for! :) I'll just need to amend it so that it stops running through the chain after the first success, but that's easy to do.

The dependency injection is just to make our unit testing easier (I'm still fairly new to thinking in a unit testable way)... I've realised being able to inject my own class gives me the ability to do things like:

  • Mock provider responses (so that I can test fail over to a backup, or admin alerts should all providers "fail")
  • Test providers would receive the right info such as email addresses, API keys etc by making sure their expectations are met when called, yet not have to actually send any emails out. (although that's free for us, our text provider isn't and mistakes could be costly!)

That's great though... that's put me on the right track.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.