AttachedObject.php 618 B

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