You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
829 B

  1. <?php
  2. namespace OSM\Element\Member;
  3. class Member {
  4. public int $ref;
  5. public string $role;
  6. public static function createFromArray($array) {
  7. assert(is_array($array));
  8. $hasType = isset($array['type']);
  9. assert($hasType);
  10. $className = __NAMESPACE__.'\\'.ucfirst($array['type']);
  11. $hasClass = class_exists($className);
  12. $instance = new $className();
  13. $hasRef = isset($array['ref']);
  14. assert($hasRef);
  15. $instance->ref = (int) $array['ref'];
  16. $hasRole = isset($array['role']);
  17. assert($hasRole);
  18. $instance->role = (string) $array['role'];
  19. $instance->completeFromArray($array);
  20. return $instance;
  21. }
  22. public function isSame(Member $other): bool {
  23. return ($this->ref === $other->ref);
  24. }
  25. }