Curl.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * This is a PHP library that handles calling reCAPTCHA.
  4. *
  5. * @copyright Copyright (c) 2015, Google Inc.
  6. * @link https://www.google.com/recaptcha
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. namespace ReCaptcha\RequestMethod;
  27. /**
  28. * Convenience wrapper around the cURL functions to allow mocking.
  29. */
  30. class Curl
  31. {
  32. /**
  33. * @see http://php.net/curl_init
  34. * @param string $url
  35. * @return resource cURL handle
  36. */
  37. public function init($url = null)
  38. {
  39. return curl_init($url);
  40. }
  41. /**
  42. * @see http://php.net/curl_setopt_array
  43. * @param resource $ch
  44. * @param array $options
  45. * @return bool
  46. */
  47. public function setoptArray($ch, array $options)
  48. {
  49. return curl_setopt_array($ch, $options);
  50. }
  51. /**
  52. * @see http://php.net/curl_exec
  53. * @param resource $ch
  54. * @return mixed
  55. */
  56. public function exec($ch)
  57. {
  58. return curl_exec($ch);
  59. }
  60. /**
  61. * @see http://php.net/curl_close
  62. * @param resource $ch
  63. */
  64. public function close($ch)
  65. {
  66. curl_close($ch);
  67. }
  68. }