Closed markushausammann closed 9 years ago
I wonder if we could get some mileage and keep our depencies low by refactoring the main fetchDocument
to look something like:
$uri = buildUri
$response = requestDocument($uri)
if ($response->success) {
handleSuccess($response)
} else {
handleError($response)
}
Would that be enough boundaries to cut on, or are we better off just using guzzle?
I would also like to avoid a dependency that is so much fatter than the actual library. Guzzle is a really well written and well maintained piece of PHP software (and almost every bigger PHP project requires it anyways) but still for an API with basically one endpoint it seems overkill. So I think we should rather write a minimal wrapper ourselves. At least I would inject an interface so we can use a mock for testing.
Kind of how I feel. Let this rock in your noodle for a second. Woudl guzzle be worth adding if we were also adding support for async documents?
Made a very simple domain specific solution that gives the possibility to inject a mock for testing and also gives everyone else the possibility to inject their own implementation. I'll make another ticket for async.
Would hide the ugliness of curl and also provide needed abstraction to write unit tests for the most important method in that library.