Retrieve.php 685 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Stripe\ApiOperations;
  3. /**
  4. * Trait for retrievable resources. Adds a `retrieve()` static method to the
  5. * class.
  6. *
  7. * This trait should only be applied to classes that derive from StripeObject.
  8. */
  9. trait Retrieve
  10. {
  11. /**
  12. * @param array|string $id The ID of the API resource to retrieve,
  13. * or an options array containing an `id` key.
  14. * @param array|string|null $opts
  15. *
  16. * @return \Stripe\StripeObject
  17. */
  18. public static function retrieve($id, $opts = null)
  19. {
  20. $opts = \Stripe\Util\RequestOptions::parse($opts);
  21. $instance = new static($id, $opts);
  22. $instance->refresh();
  23. return $instance;
  24. }
  25. }