Delete.php 734 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Stripe\ApiOperations;
  3. /**
  4. * Trait for deletable resources. Adds a `delete()` method to the class.
  5. *
  6. * This trait should only be applied to classes that derive from StripeObject.
  7. */
  8. trait Delete
  9. {
  10. /**
  11. * @param null|array $params
  12. * @param null|array|string $opts
  13. *
  14. * @throws \Stripe\Exception\ApiErrorException if the request fails
  15. *
  16. * @return static the deleted resource
  17. */
  18. public function delete($params = null, $opts = null)
  19. {
  20. self::_validateParams($params);
  21. $url = $this->instanceUrl();
  22. list($response, $opts) = $this->_request('delete', $url, $params, $opts);
  23. $this->refreshFrom($response, $opts);
  24. return $this;
  25. }
  26. }