-
Notifications
You must be signed in to change notification settings - Fork 2k
Added feature to inject custom HTTP clients #84
Added feature to inject custom HTTP clients #84
Conversation
Great work! Love the idea of injectable HTTP client handler :) Here's my 2cents:
Reasoning: Hope this is useful and makes sense :) Cheers! |
I'm supportive of this and the Stream client inclusion and fallback. Great stuff Sammy. |
/** | ||
* @param FacebookCurl|null Procedural curl as object | ||
*/ | ||
public function __construct($facebookCurl = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing type hint
Whaoo great work ! Much better than what I'd send ;) |
Thanks for the feedback guys! :) @ahsanity & @gfosco Sweet - I'll add the Guzzle and stream implementations in another PR with the stream implementation fallback. That way this PR doesn't get too out of scope. :) @yguedidi Thanks for the code review! I'll def tweak some of your callouts. On moving On mockery - I included it because it has really become the de facto standard in mocking objects in PHPUnit and has a lot more power and flexibility when mocking an object than PHPUnit's mocking capabilities. |
Done! This commit should merge without conflicts. @yguedidi - On moving the curl bug fix to |
Onward and upward. |
Added feature to inject custom HTTP clients
W00t, w00t! 👍 |
Take a deep breath...! The very much needed injectable HTTP client handler PR is here! :) This would close #4.
Usage
You can inject your own HTTP client in two steps:
Facebook\FacebookHttpable
interface.I've posted examples of Guzzle and stream wrapper implementations.
Considerations
FacebookRequest
object in this refactor. Theexecute()
method was especially getting out of hand. It's not perfect yet, but it's much better than before.composer.json
file. It pulls in mockery so that we can mock dependancies. The test suite doesn't test in isolation enough and mockery will make it easier to do that going forward. So make sure to runcomposer update
when you pull this one in to test.The end
Let me know if you have any questions on anything!