Create.php 770 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Stripe\ApiOperations;
  3. /**
  4. * Trait for creatable resources. Adds a `create()` static method to the class.
  5. *
  6. * This trait should only be applied to classes that derive from StripeObject.
  7. */
  8. trait Create
  9. {
  10. /**
  11. * @param array|null $params
  12. * @param array|string|null $options
  13. *
  14. * @return \Stripe\ApiResource The created resource.
  15. */
  16. public static function create($params = null, $options = null)
  17. {
  18. self::_validateParams($params);
  19. $url = static::classUrl();
  20. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  21. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  22. $obj->setLastResponse($response);
  23. return $obj;
  24. }
  25. }