php-mod / curl

This library provides an object-oriented and dependency free wrapper of the PHP cURL extension.
MIT License
328 stars 120 forks source link

Added status check functions #30

Closed stevepatter closed 7 years ago

stevepatter commented 7 years ago

I've added HTTP status check functions that I've found useful, and may make it simpler to script around the curl library.

Now, a user can run

$curl = new Curl();
$curl->get('http://www.github.com/');
if ($curl->isSuccess()) {
    // handle curl response
} else {
    throw new Exception('failed to fetch content');
}

rather than having to check for specific http status codes. Of course, they still have access to the full status code should that be required.

stevepatter commented 7 years ago

I've adjusted the code for PSR-2 standards & it now passes PHP5 tests on Travis. Looks like the PHP7 & HHVM setup might be misconfigured.

amouhzi commented 7 years ago

Thank you