AttachedObject.php 675 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace Stripe;
  3. /**
  4. * Class AttachedObject
  5. *
  6. * e.g. metadata on Stripe objects.
  7. *
  8. * @package Stripe
  9. */
  10. class AttachedObject extends StripeObject
  11. {
  12. /**
  13. * Updates this object.
  14. *
  15. * @param array $properties A mapping of properties to update on this object.
  16. */
  17. public function replaceWith($properties)
  18. {
  19. $removed = array_diff(array_keys($this->_values), array_keys($properties));
  20. // Don't unset, but rather set to null so we send up '' for deletion.
  21. foreach ($removed as $k) {
  22. $this->$k = null;
  23. }
  24. foreach ($properties as $k => $v) {
  25. $this->$k = $v;
  26. }
  27. }
  28. }