SingletonApiResource.php 724 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Stripe;
  3. /**
  4. * Class SingletonApiResource.
  5. */
  6. abstract class SingletonApiResource extends ApiResource
  7. {
  8. /**
  9. * @return string the endpoint associated with this singleton class
  10. */
  11. public static function classUrl()
  12. {
  13. // Replace dots with slashes for namespaced resources, e.g. if the object's name is
  14. // "foo.bar", then its URL will be "/v1/foo/bar".
  15. /** @phpstan-ignore-next-line */
  16. $base = \str_replace('.', '/', static::OBJECT_NAME);
  17. return "/v1/{$base}";
  18. }
  19. /**
  20. * @return string the endpoint associated with this singleton API resource
  21. */
  22. public function instanceUrl()
  23. {
  24. return static::classUrl();
  25. }
  26. }