expectedbehavior / php-docraptor

PHP consumer for the DocRaptor.com API
ISC License
7 stars 1 forks source link

Use Guzzle as a curl wrapper #21

Closed markushausammann closed 9 years ago

markushausammann commented 9 years ago

Would hide the ugliness of curl and also provide needed abstraction to write unit tests for the most important method in that library.

janxious commented 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?

markushausammann commented 9 years ago

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.

janxious commented 9 years ago

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?

markushausammann commented 9 years ago

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.