/** * Return the * @param \Gedcomx\Conclusion\Person $spouse * * @return ChildAndParentsRelationship|null */ public function findChildAndParentsRelationshipTo(Person $spouse) { $relationships = $this->getChildAndParentsRelationships(); if (relationships != null) { foreach ($relationships as $relation) { $personReference = $relation->getFather(); if ($personReference != null) { $reference = $personReference->getResource()->toString(); if ($reference == "#" . $spouse->getId()) { return $relation; } } $personReference = $relation->getMother(); if ($personReference != null) { $reference = $personReference->getResource()->toString(); if ($reference == "#" . $spouse->getId()) { return $relation; } } } } return null; }
/** * Finds the relationship to the specified child. * This method iterates over the current relationships, and each item is examined * to determine if the child ID in the relationship matches the child ID for the specified child. If one is found, * that relationship object containing that child ID is returned, and no other relationships are examined further. * * @param \Gedcomx\Conclusion\Person $child * * @return \Gedcomx\Conclusion\Relationship|null */ public function findRelationshipTo(Person $child) { $relationships = $this->getRelationships(); if ($relationships != null) { foreach ($relationships as $relationship) { $childReference = $relationship->getPerson2(); if ($childReference != null) { $reference = $childReference->getResource(); if ($reference == "#" . $child->getId()) { return $relationship; } } } } return null; }
/** * Finds the relationship to the specified parent. * This method iterates over the current person's relationships, and each item is examined * to determine if the parent ID in the relationship matches the parent ID for the specified parent. If one is found, * that relationship object containing that parent ID is returned, and no other relationships are examined further. * * @param Person $parent * @return Relationship|null */ public function findRelationshipTo(Person $parent) { $relationships = $this->getRelationships(); if ($relationships) { foreach ($relationships as $relationship) { if ($relationship->getPerson2() && $relationship->getPerson2()->getResource() && $relationship->getPerson2()->getResource() == '#' . $parent->getId()) { return $relationship; } } } return null; }