gedcomx-php-client
  • Namespace
  • Class

Namespaces

  • Gedcomx
    • Agent
    • Atom
    • Common
    • Conclusion
    • Extensions
      • FamilySearch
        • Platform
          • Artifacts
          • Discussions
          • Tree
          • Users
        • Rs
          • Client
            • FamilyTree
            • Helpers
            • Memories
            • Util
        • Rt
        • Types
    • GedcomxFile
    • Links
    • Records
    • Rs
      • Client
        • Exception
        • Options
        • Util
    • Rt
    • Search
    • Source
    • Support
    • Types
    • Util
    • Vocab

Classes

  • Gedcomx\Agent\Address
  • Gedcomx\Agent\Agent
  • Gedcomx\Agent\OnlineAccount
  • Gedcomx\Atom\Category
  • Gedcomx\Atom\CommonAttributes
  • Gedcomx\Atom\Content
  • Gedcomx\Atom\Entry
  • Gedcomx\Atom\ExtensibleElement
  • Gedcomx\Atom\Feed
  • Gedcomx\Atom\Generator
  • Gedcomx\Atom\Person
  • Gedcomx\Common\Attribution
  • Gedcomx\Common\CustomEntity
  • Gedcomx\Common\CustomKeyedItem
  • Gedcomx\Common\EvidenceReference
  • Gedcomx\Common\ExtensibleData
  • Gedcomx\Common\Note
  • Gedcomx\Common\Qualifier
  • Gedcomx\Common\ResourceReference
  • Gedcomx\Common\TextValue
  • Gedcomx\Common\UniqueCustomKeyedItem
  • Gedcomx\Conclusion\Conclusion
  • Gedcomx\Conclusion\DateInfo
  • Gedcomx\Conclusion\DisplayProperties
  • Gedcomx\Conclusion\Document
  • Gedcomx\Conclusion\Event
  • Gedcomx\Conclusion\EventRole
  • Gedcomx\Conclusion\Fact
  • Gedcomx\Conclusion\Gender
  • Gedcomx\Conclusion\Identifier
  • Gedcomx\Conclusion\Name
  • Gedcomx\Conclusion\NameForm
  • Gedcomx\Conclusion\NamePart
  • Gedcomx\Conclusion\Person
  • Gedcomx\Conclusion\PlaceDescription
  • Gedcomx\Conclusion\PlaceDisplayProperties
  • Gedcomx\Conclusion\PlaceReference
  • Gedcomx\Conclusion\Relationship
  • Gedcomx\Conclusion\Subject
  • Gedcomx\Extensions\FamilySearch\Error
  • Gedcomx\Extensions\FamilySearch\FamilySearchPlatform
  • Gedcomx\Extensions\FamilySearch\Feature
  • Gedcomx\Extensions\FamilySearch\HealthConfig
  • Gedcomx\Extensions\FamilySearch\Platform\Artifacts\ArtifactMetadata
  • Gedcomx\Extensions\FamilySearch\Platform\Artifacts\ArtifactType
  • Gedcomx\Extensions\FamilySearch\Platform\Discussions\Comment
  • Gedcomx\Extensions\FamilySearch\Platform\Discussions\Discussion
  • Gedcomx\Extensions\FamilySearch\Platform\Error
  • Gedcomx\Extensions\FamilySearch\Platform\HealthConfig
  • Gedcomx\Extensions\FamilySearch\Platform\Tag
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeInfo
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeObjectModifier
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeObjectType
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChangeOperation
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\DiscussionReference
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MatchInfo
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MatchStatus
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\Merge
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MergeAnalysis
  • Gedcomx\Extensions\FamilySearch\Platform\Tree\MergeConflict
  • Gedcomx\Extensions\FamilySearch\Platform\Users\User
  • Gedcomx\Extensions\FamilySearch\Rs\Client\DiscussionsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\DiscussionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchClient
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchCollectionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaceDescriptionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaces
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchPlaceState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchSourceDescriptionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchStateFactory
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChangeHistoryState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChildAndParentsRelationshipState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeCollectionState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonChildrenState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonParentsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreePersonState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeRelationshipsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeRelationshipState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeStateFactory
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Helpers\FamilySearchRequest
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Memories\FamilySearchMemories
  • Gedcomx\Extensions\FamilySearch\Rs\Client\PersonMatchResultsState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\PersonMergeState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\PersonNonMatchesState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Rel
  • Gedcomx\Extensions\FamilySearch\Rs\Client\UserHistoryState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\UserState
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\ChangeEntry
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\ChangeHistoryPage
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\LoggerMiddleware
  • Gedcomx\Extensions\FamilySearch\Rs\Client\Util\ThrottlingMiddleware
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformLocalReferenceResolver
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformModelVisitorBase
  • Gedcomx\Extensions\FamilySearch\Tag
  • Gedcomx\Extensions\FamilySearch\Types\FactType
  • Gedcomx\Gedcomx
  • Gedcomx\GedcomxFile\DefaultJsonSerialization
  • Gedcomx\GedcomxFile\DefaultXMLSerialization
  • Gedcomx\GedcomxFile\GedcomxFile
  • Gedcomx\GedcomxFile\GedcomxFileEntry
  • Gedcomx\GedcomxFile\GedcomxOutput
  • Gedcomx\GedcomxFile\Manifest
  • Gedcomx\GedcomxFile\ManifestAttribute
  • Gedcomx\Links\HypermediaEnabledData
  • Gedcomx\Links\Link
  • Gedcomx\Records\Collection
  • Gedcomx\Records\CollectionContent
  • Gedcomx\Records\Field
  • Gedcomx\Records\FieldDescriptor
  • Gedcomx\Records\FieldValue
  • Gedcomx\Records\FieldValueDescriptor
  • Gedcomx\Records\RecordDescriptor
  • Gedcomx\Records\RecordSet
  • Gedcomx\Records\RecordSetIterator
  • Gedcomx\Rs\Client\AgentState
  • Gedcomx\Rs\Client\AncestryResultsState
  • Gedcomx\Rs\Client\CollectionsState
  • Gedcomx\Rs\Client\CollectionState
  • Gedcomx\Rs\Client\DescendancyResultsState
  • Gedcomx\Rs\Client\GedcomxApplicationState
  • Gedcomx\Rs\Client\GedcomxSearchQuery
  • Gedcomx\Rs\Client\Options\CacheDirectives
  • Gedcomx\Rs\Client\Options\HeaderParameter
  • Gedcomx\Rs\Client\Options\Preconditions
  • Gedcomx\Rs\Client\Options\QueryParameter
  • Gedcomx\Rs\Client\PersonChildrenState
  • Gedcomx\Rs\Client\PersonParentsState
  • Gedcomx\Rs\Client\PersonSearchResultsState
  • Gedcomx\Rs\Client\PersonSpousesState
  • Gedcomx\Rs\Client\PersonsState
  • Gedcomx\Rs\Client\PersonState
  • Gedcomx\Rs\Client\PlaceDescriptionsState
  • Gedcomx\Rs\Client\PlaceDescriptionState
  • Gedcomx\Rs\Client\PlaceGroupState
  • Gedcomx\Rs\Client\PlaceSearchResultsState
  • Gedcomx\Rs\Client\RecordsState
  • Gedcomx\Rs\Client\RecordState
  • Gedcomx\Rs\Client\Rel
  • Gedcomx\Rs\Client\RelationshipsState
  • Gedcomx\Rs\Client\RelationshipState
  • Gedcomx\Rs\Client\SearchParameter
  • Gedcomx\Rs\Client\SourceDescriptionsState
  • Gedcomx\Rs\Client\SourceDescriptionState
  • Gedcomx\Rs\Client\StateFactory
  • Gedcomx\Rs\Client\Util\AncestryNode
  • Gedcomx\Rs\Client\Util\AncestryTree
  • Gedcomx\Rs\Client\Util\DataSource
  • Gedcomx\Rs\Client\Util\DescendancyNode
  • Gedcomx\Rs\Client\Util\DescendancyTree
  • Gedcomx\Rs\Client\Util\EmbeddedLinkLoader
  • Gedcomx\Rs\Client\Util\Embedding
  • Gedcomx\Rs\Client\Util\GedcomxBaseSearchQueryBuilder
  • Gedcomx\Rs\Client\Util\GedcomxPersonSearchQueryBuilder
  • Gedcomx\Rs\Client\Util\GedcomxPlaceSearchQueryBuilder
  • Gedcomx\Rs\Client\Util\HttpStatus
  • Gedcomx\Rs\Client\Util\RdfCollection
  • Gedcomx\Rs\Client\Util\RdfNode
  • Gedcomx\Rs\Client\Util\SearchParameter
  • Gedcomx\Rs\Client\VocabConstants
  • Gedcomx\Rs\Client\VocabElementListState
  • Gedcomx\Rs\Client\VocabElementState
  • Gedcomx\Rt\GedcomxLocalReferenceResolver
  • Gedcomx\Rt\GedcomxModelVisitorBase
  • Gedcomx\Search\ResultConfidence
  • Gedcomx\Source\CitationField
  • Gedcomx\Source\Coverage
  • Gedcomx\Source\SourceCitation
  • Gedcomx\Source\SourceDescription
  • Gedcomx\Source\SourceReference
  • Gedcomx\Types\ConfidenceLevel
  • Gedcomx\Types\DocumentType
  • Gedcomx\Types\EventRoleType
  • Gedcomx\Types\EventType
  • Gedcomx\Types\FactType
  • Gedcomx\Types\FieldType
  • Gedcomx\Types\FieldValueType
  • Gedcomx\Types\GenderType
  • Gedcomx\Types\IdentifierType
  • Gedcomx\Types\NamePartType
  • Gedcomx\Types\NameType
  • Gedcomx\Types\RecordType
  • Gedcomx\Types\RelationshipType
  • Gedcomx\Types\ResourceType
  • Gedcomx\Util\Collection
  • Gedcomx\Util\Duration
  • Gedcomx\Util\FormalDate
  • Gedcomx\Util\JsonMapper
  • Gedcomx\Util\SimpleDate
  • Gedcomx\Util\XmlMapper
  • Gedcomx\Vocab\VocabElement
  • Gedcomx\Vocab\VocabElementList

Interfaces

  • Gedcomx\Common\Attributable
  • Gedcomx\Common\HasNotes
  • Gedcomx\Conclusion\HasFacts
  • Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\PreferredRelationshipState
  • Gedcomx\Extensions\FamilySearch\Rt\FamilySearchPlatformModelVisitor
  • Gedcomx\GedcomxFile\GedcomxEntryDeserializer
  • Gedcomx\GedcomxFile\GedcomxEntrySerializer
  • Gedcomx\Links\SupportsLinks
  • Gedcomx\Records\HasFields
  • Gedcomx\Rs\Client\Options\StateTransitionOption
  • Gedcomx\Rs\Client\SupportsExtensionElements
  • Gedcomx\Rt\GedcomxModelVisitor
  • Gedcomx\Source\ReferencesSources
  • Gedcomx\Support\HasJsonKey

Exceptions

  • Gedcomx\GedcomxFile\GedcomxFileException
  • Gedcomx\Rs\Client\Exception\GedcomxApplicationException
  • Gedcomx\Rs\Client\Exception\GedcomxInvalidQueryParameter
  • Gedcomx\Rs\Client\Exception\NullValueException
   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  101  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116  117  118  119  120  121  122  123  124  125  126  127  128  129  130  131  132  133  134  135  136  137  138  139  140  141  142  143  144  145  146  147  148  149  150  151  152  153  154  155  156  157  158  159  160  161  162  163  164  165  166  167  168  169  170  171  172  173  174  175  176  177  178  179  180  181  182  183  184  185  186  187  188  189  190  191  192  193  194  195  196  197  198  199  200  201  202  203  204  205  206  207  208  209  210  211  212  213  214  215  216  217  218  219  220  221  222  223  224  225  226  227  228  229  230  231  232  233  234  235  236  237  238  239  240  241  242  243  244  245  246  247  248  249  250  251  252  253  254  255  256  257  258  259  260  261  262  263  264  265  266  267  268  269  270  271  272  273  274  275  276  277  278  279  280  281  282  283  284  285  286  287  288  289  290  291  292  293  294  295  296  297  298  299  300  301  302  303  304  305  306  307  308  309  310  311  312  313  314  315  316  317  318  319  320  321  322  323  324  325  326  327  328  329  330  331  332  333  334  335  336  337  338  339  340  341  342  343  344  345  346  347  348  349  350  351  352  353  354  355  356  357  358  359  360  361  362  363  364  365  366  367  368  369  370  371  372  373  374  375  376  377  378  379  380  381  382  383  384  385  386  387  388  389  390  391  392  393  394  395  396  397  398  399  400  401  402  403  404  405  406  407  408  409  410  411  412  413  414  415  416  417  418  419  420  421  422  423  424  425  426  427  428  429  430  431  432  433  434  435  436  437  438  439  440  441  442  443  444  445  446  447  448  449  450  451  452  453  454  455  456  457  458  459  460  461  462  463  464  465  466  467  468  469  470  471  472  473  474  475  476  477  478  479  480  481  482  483  484  485  486  487  488  489  490  491  492  493  494  495  496  497  498  499  500  501  502  503  504  505  506  507  508  509  510  511  512  513  514  515  516  517  518  519  520  521  522  523  524  525  526  527  528  529  530  531  532  533  534  535  536  537  538  539  540  541  542  543  544  545  546  547  548  549  550  551  552  553  554  555  556  557  558  559  560  561  562  563  564  565  566  567  568  569  570  571  572  573  574  575  576  577  578  579  580  581  582  583  584  585  586  587  588  589  590  591  592  593  594  595  596  597  598  599  600  601  602  603  604  605  606  607  608  609  610  611  612  613  614  615  616  617  618  619  620  621  622  623  624  625  626  627  628  629  630  631  632  633  634  635  636  637  638  639  640  641  642  643  644  645  646  647  648  649  650  651  652  653  654  655  656  657  658  659  660  661  662  663  664  665  666  667  668  669  670  671  672  673  674  675  676  677  678  679  680  681  682  683  684  685  686  687  688  689  690  691  692  693  694  695  696  697  698  699  700  701  702  703  704  705  706  707  708  709  710  711  712  713  714  715  716  717  718  719  720  721  722  723  724  725  726  727  728  729  730  731  732  733  734  735  736  737  738  739  740  741  742  743  744  745  746  747  748  749  750  751  752  753  754  755  756  757  758  759  760  761  762  763  764  765  766  767  768  769  770  771  772  773  774  775  776  777  778  779  780  781  782  783  784  785  786  787  788  789  790  791  792  793  794  795  796  797  798  799  800  801  802  803  804  805  806  807  808  809  810  811  812  813  814  815  816  817  818  819  820  821  822  823  824  825  826  827  828  829  830  831  832  833  834  835  836  837  838  839  840  841  842  843  844  845  846  847  848  849  850  851  852  853  854  855  856  857  858  859  860  861  862  863  864  865  866  867  868  869  870  871  872  873  874  875  876  877  878  879  880  881  882  883  884  885  886  887  888  889  890  891  892  893  894  895  896  897  898  899  900  901  902  903  904  905  906  907  908  909  910  911  912  913  914  915  916  917  918  919  920  921  922  923  924  925  926  927  928  929  930  931  932  933  934  935  936  937  938  939  940  941  942  943  944  945  946  947  948  949  950  951  952  953  954  955  956  957  958  959  960  961  962  963  964  965  966  967  968  969  970  971  972  973  974  975  976  977  978  979  980  981  982  983  984  985  986  987  988  989  990  991  992  993  994  995  996  997  998  999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 
<?php

namespace Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree;

use Gedcomx\Common\EvidenceReference;
use Gedcomx\Common\Note;
use Gedcomx\Common\ResourceReference;
use Gedcomx\Conclusion\Conclusion;
use Gedcomx\Conclusion\Fact;
use Gedcomx\Extensions\FamilySearch\FamilySearchPlatform;
use Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship;
use Gedcomx\Extensions\FamilySearch\Rs\Client\FamilySearchCollectionState;
use Gedcomx\Extensions\FamilySearch\Rs\Client\Helpers\FamilySearchRequest;
use Gedcomx\Extensions\FamilySearch\Rs\Client\Rel;
use Gedcomx\Links\Link;
use Gedcomx\Rs\Client\Exception\GedcomxApplicationException;
use Gedcomx\Rs\Client\Options\StateTransitionOption;
use Gedcomx\Rs\Client\PersonState;
use Gedcomx\Rs\Client\SourceDescriptionState;
use Gedcomx\Source\SourceReference;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;

/**
 * Class ChildAndParentsRelationshipState
 *
 * @package Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree
 *
 *          The ChildAndParentsRelationshipState exposes management and other FamilySearch specific functions for a children and parents.
 *
 */
class ChildAndParentsRelationshipState extends FamilySearchCollectionState implements PreferredRelationshipState
{

    /**
     * Clones the current instance of ChildAndParentsRelationshipState
     *
     * @param \GuzzleHttp\Psr7\Request  $request
     * @param \GuzzleHttp\Psr7\Response $response
     *
     * @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChildAndParentsRelationshipState
     */
    protected function reconstruct(Request $request, Response $response)
    {
        return new ChildAndParentsRelationshipState($this->client, $request, $response, $this->accessToken, $this->stateFactory);
    }

    /**
     * Returns the relationship object represented by this state, if any
     *
     * @return \Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship|null
     */
    protected function getScope()
    {
        return $this->getRelationship();
    }

    /**
     * Define the rel for this state as a fallback if it cannot be determined from the state data
     *
     * @return string
     */
    public function getSelfRel()
    {
        return Rel::RELATIONSHIP;
    }

    /**
     * Returns the relationship object represented by this state, if any
     *
     * @return ChildAndParentsRelationship|null
     */
    public function getRelationship()
    {
        if ($this->getEntity() != null) {
            $relationships = $this->getEntity()->getChildAndParentsRelationships();
            if ($relationships != null && !empty($relationships)) {
                return $relationships[0];
            }
        }
        return null;
    }

    /**
     * Gets the first conclusion for this relationship. FatherFact is returned first if it is not null; otherwise, MotherFact is returned.
     *
     * @return Conclusion
     */
    public function getConclusion()
    {
        return $this->getFatherFact() != null ? $this->getFatherFact()
            : $this->getMotherFact() != null ? $this->getMotherFact()
                : null;
    }

    /**
     * Return the first fact associated with the father
     *
     * @return \Gedcomx\Conclusion\Fact|null
     */
    public function getFatherFact()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            $facts = $relationship->getFatherFacts();
            if ($facts != null && !empty($facts)) {
                return $facts[0];
            }
        }

        return null;
    }

    /**
     * Return the first fact associated with the mother
     *
     * @return \Gedcomx\Conclusion\Fact|null
     */
    public function getMotherFact()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            $facts = $relationship->getMotherFacts();
            if ($facts != null && !empty($facts)) {
                return $facts[0];
            }
        }

        return null;
    }

    /**
     * Gets the first Note from the current Relationship.
     *
     * @return Note|null
     */
    public function getNote()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            $notes = $relationship->getNotes();
            if ($notes != null && !empty($notes)) {
                return $notes[0];
            }
        }

        return null;
    }

    /**
     * Return the first source reference for this relationship
     *
     * @return \Gedcomx\Source\SourceReference|null
     */
    public function getSourceReference()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            $sources = $relationship->getSources();
            if ($sources != null && !empty($sources)) {
                return $sources[0];
            }
        }

        return null;
    }

    /**
     * Return the first evidence reference for this relationship
     *
     * @return \Gedcomx\Common\EvidenceReference|null
     */
    public function getEvidenceReference()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            $evidence = $relationship->getEvidence();
            if ($evidence != null && !empty($evidence)) {
                return $evidence[0];
            }
        }

        return null;
    }

    /**
     * Return the first media reference for this relationship
     *
     * @return \Gedcomx\Source\SourceReference|null
     */
    public function getMediaReference()
    {
        $relationship = $this->getRelationship();
        if ($relationship != null) {
            $media = $relationship->getMedia();
            if ($media != null && !empty($media)) {
                return $media[0];
            }
        }

        return null;
    }

    /**
     * Get a copy of this object's collection state
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\FamilyTreeCollectionState|null
     */
    public function readCollection(StateTransitionOption $option = null)
    {
        $link = $this->getLink(Rel::COLLECTION);
        if ($link == null || $link->getHref() == null) {
            return null;
        }

        $request = $this->createAuthenticatedGedcomxRequest('GET', $link->getHref());
        return $this->stateFactory->createState(
            'CollectionState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken);
    }

    /**
     * Create a request object to retrieve embedded resources
     *
     * @param string              $method
     * @param \Gedcomx\Links\Link $link
     *
     * @return \GuzzleHttp\Psr7\Request
     */
    protected function createRequestForEmbeddedResource($method, Link $link)
    {
        return $this->createAuthenticatedGedcomxRequest($method, $link->getHref(), FamilySearchRequest::getMediaTypes());
    }

    /**
     * Load an embedded resource for this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return $this
     */
    public function loadEmbeddedResource(StateTransitionOption $option = null)
    {
        $this->passOptionsTo('includeEmbeddedResources', array($this->entity), func_get_args());
        return $this;
    }

    /**
     * Load the embedded resources for this relationship
     *
     * @param array                                            $rels
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState|null
     */
    public function loadEmbeddedResources(array $rels, StateTransitionOption $option = null)
    {
        foreach ($rels as $rel) {
            $link = $this->getLink($rel);
            if ($this->entity != null && $link != null && $link->getHref() != null) {
                $this->passOptionsTo('embed', array($link), func_get_args());
            }
        }
        return $this;
    }

    /**
     * Load conclusion data for this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function loadConclusions(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::CONCLUSIONS)), func_get_args());
    }

    /**
     * Load source references for this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function loadSourceReferences(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::SOURCE_REFERENCES)), func_get_args());
    }

    /**
     * Load media references for this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function loadMediaReferences(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::MEDIA_REFERENCES)), func_get_args());
    }

    /**
     * Load evidence references for this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function loadEvidenceReferences(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::EVIDENCE_REFERENCES)), func_get_args());
    }

    /**
     * Load the notes for this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function loadNotes(StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('loadEmbeddedResources', array(array(Rel::NOTES)), func_get_args());
    }

    /**
     * Create an copy of this state with no data.
     *
     * @return ChildAndParentsRelationship
     */
    protected function createEmptySelf()
    {
        $relationship = new ChildAndParentsRelationship();
        $relationship->setId($this->getLocalSelfId());
        return $relationship;
    }

    /**
     * Get the ID of this relationship. Returns null if get() has not been called to hydrate the relationship.
     *
     * @return null|string
     */
    protected function getLocalSelfId()
    {
        $me = $this->getRelationship();
        return $me == null ? null : $me->getId();
    }

    /**
     * Add a fact to the father in this relationship
     *
     * @param \Gedcomx\Conclusion\Fact                         $fact
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addFatherFact(Fact $fact, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addFatherFacts', array(array($fact)), func_get_args());
    }

    /**
     * Add a list of facts to the father in this relationship
     *
     * @param \Gedcomx\Conclusion\Fact[]                       $facts
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addFatherFacts(array $facts, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setFatherFacts($facts);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::CONCLUSIONS), func_get_args());
    }

    /**
     * Update the specified father fact on the current relationship.
     *
     * @param \Gedcomx\Conclusion\Fact                         $fact
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateFatherFact(Fact $fact, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateFatherFacts', array(array($fact)), func_get_args());
    }

    /**
     * Update a list of facts on the father.
     *
     * @param \Gedcomx\Conclusion\Fact[]                                            $facts
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateFatherFacts(array $facts, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setFatherFacts($facts);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::CONCLUSIONS), func_get_args());
    }

    /**
     * Add a fact to the mother in this relationship
     *
     * @param \Gedcomx\Conclusion\Fact                         $fact
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addMotherFact(Fact $fact, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addMotherFacts', array(array($fact)), func_get_args());
    }

    /**
     * Add a list of facts to the mother in this relationship
     *
     * @param \Gedcomx\Conclusion\Fact[]                                            $facts
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addMotherFacts(array $facts, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setMotherFacts($facts);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::CONCLUSIONS), func_get_args());
    }

    /**
     * Update a fact on the mother in this relationship
     *
     * @param \Gedcomx\Conclusion\Fact                         $fact
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateMotherFact(Fact $fact, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateMotherFacts', array(array($fact)), func_get_args());
    }

    /**
     * Update a list of facts on the mother in this relationship
     *
     * @param \Gedcomx\Conclusion\Fact[]                                            $facts
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateMotherFacts(array $facts, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setMotherFacts($facts);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::CONCLUSIONS), func_get_args());
    }

    /**
     * Delete a fact from this relationship
     *
     * @param \Gedcomx\Conclusion\Fact                         $fact
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     * @throws GedcomxApplicationException
     */
    public function deleteFact(Fact $fact, StateTransitionOption $option = null)
    {
        $link = $fact->getLink(Rel::CONCLUSION);
        $link = $link == null ? $fact->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Conclusion cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken);
    }

    /**
     * Add a source reference to this relationship using a state object
     *
     * @param \Gedcomx\Rs\Client\SourceDescriptionState        $source
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addSourceReferenceState(SourceDescriptionState $source, StateTransitionOption $option = null)
    {
        $reference = new SourceReference();
        $reference->setDescriptionRef($source->getSelfUri());
        return $this->passOptionsTo('addSourceReference', array($reference), func_get_args());
    }

    /**
     * Add a source reference to this relationship using a SourceReference object
     *
     * @param \Gedcomx\Source\SourceReference                  $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addSourceReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addSourceReferences', array(array($reference)), func_get_args());
    }

    /**
     * Add a list of source references to this relationship
     *
     * @param \Gedcomx\Source\SourceReference[]                $refs
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addSourceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setSources($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::SOURCE_REFERENCES), func_get_args());
    }

    /**
     * Update a source reference on this relationship
     *
     * @param \Gedcomx\Source\SourceReference                  $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateSourceReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateSourceReferences', array(array($reference)), func_get_args());
    }

    /**
     * Update a list of source references on this relationship
     *
     * @param \Gedcomx\Source\SourceReference[]                $refs
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateSourceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setSources($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::SOURCE_REFERENCES), func_get_args());
    }

    /**
     * Delete a source reference from this relationship
     *
     * @param \Gedcomx\Source\SourceReference                  $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     * @throws GedcomxApplicationException
     */
    public function deleteSourceReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        $link = $reference->getLink(Rel::SOURCE_REFERENCE);
        $link = $link == null ? $reference->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Source reference cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Add a media reference to this relationship
     *
     * @param \Gedcomx\Source\SourceReference                  $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addMediaReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addMediaReferences', array(array($reference)), func_get_args());
    }

    /**
     * Add a list of media references to this relationship
     *
     * @param \Gedcomx\Source\SourceReference[]                $refs
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addMediaReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setMedia($refs);
        return $this->passOptionsTo('updateMediaReferences', array($relationship), func_get_args());
    }

    /**
     * Update a media reference on this relationship
     *
     * @param \Gedcomx\Source\SourceReference                  $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateMediaReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateMediaReferences', array(array($reference)), func_get_args());
    }

    /**
     * Update a list of media references for this relationship
     *
     * @param \Gedcomx\Source\SourceReference[]                $refs
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateMediaReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setMedia($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::MEDIA_REFERENCES), func_get_args());
    }

    /**
     * Delete a media reference from this relationship
     *
     * @param \Gedcomx\Source\SourceReference                  $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     * @throws GedcomxApplicationException
     */
    public function deleteMediaReference(SourceReference $reference, StateTransitionOption $option = null)
    {
        $link = $reference->getLink(Rel::MEDIA_REFERENCE);
        $link = $link == null ? $reference->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Media reference cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * And an evidence reference to this relationship
     *
     * @param \Gedcomx\Common\EvidenceReference                $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addEvidenceReference(EvidenceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addEvidenceReferences', array(array($reference)), func_get_args());
    }

    /**
     * Add a list of evidence references to this relationship
     *
     * @param \Gedcomx\Common\EvidenceReference[]              $refs
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addEvidenceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setEvidence($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::EVIDENCE_REFERENCES), func_get_args());
    }

    /**
     * Update an evidence reference on this relationship
     *
     * @param \Gedcomx\Common\EvidenceReference                $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateEvidenceReference(EvidenceReference $reference, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateEvidenceReferences', array($reference), func_get_args());
    }

    /**
     * Update a list of evidence references on this relationship
     *
     * @param \Gedcomx\Common\EvidenceReference[]              $refs
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateEvidenceReferences(array $refs, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setEvidence($refs);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::EVIDENCE_REFERENCES), func_get_args());
    }

    /**
     * Delete an evidence reference from this relationship
     *
     * @param \Gedcomx\Common\EvidenceReference                $reference
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     * @throws GedcomxApplicationException
     */
    public function deleteEvidenceReference(EvidenceReference $reference, StateTransitionOption $option = null)
    {
        $link = $reference->getLink(Rel::EVIDENCE_REFERENCE);
        $link = $link == null ? $reference->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Evidence reference cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedRequest('DELETE', $link->getHref(), FamilySearchRequest::getMediaTypes());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Read a specific note on this relationship
     *
     * @param \Gedcomx\Common\Note                             $note
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     * @throws GedcomxApplicationException
     */
    public function readNote(Note $note, StateTransitionOption $option = null)
    {
        $link = $note->getLink(Rel::NOTE);
        $link = $link == null ? $note->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Note cannot be read: missing link.");
        }

        $request = $this->createAuthenticatedRequest('GET', $link->getHref());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken);
    }

    /**
     * Add a note to this relationship
     *
     * @param \Gedcomx\Common\Note                             $note
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addNote(Note $note, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('addNotes', array(array($note)), func_get_args());
    }

    /**
     * Add a list of notes to this relationship
     *
     * @param \Gedcomx\Common\Note[]                           $notes
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function addNotes(array $notes, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setNotes($notes);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::NOTES), func_get_args());
    }

    /**
     * Update a note on this relationship
     *
     * @param \Gedcomx\Common\Note                             $note
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateNote(Note $note, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateNotes', array(array($note)), func_get_args());
    }

    /**
     * Update a list of notes on this relationship
     *
     * @param \Gedcomx\Common\Note[]                           $notes
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateNotes(array $notes, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setNotes($notes);
        return $this->passOptionsTo('updateRelationship', array($relationship, Rel::NOTES), func_get_args());
    }

    /**
     * Delete a note from this relationship
     *
     * @param \Gedcomx\Common\Note                             $note
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     * @throws GedcomxApplicationException
     */
    public function deleteNote(Note $note, StateTransitionOption $option = null)
    {
        $link = $note->getLink(Rel::NOTE);
        $link = $link == null ? $note->getLink(Rel::SELF) : $link;
        if ($link == null || $link->getHref() == null) {
            throw new GedcomxApplicationException("Note cannot be deleted: missing link.");
        }

        $request = $this->createAuthenticatedRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Read the change history for this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChangeHistoryState|null
     */
    public function readChangeHistory(StateTransitionOption $option = null)
    {
        $link = $this->getLink(Rel::CHANGE_HISTORY);
        if ($link == null || $link->getHref() == null) {
            return null;
        }

        $request = $this->createAuthenticatedFeedRequest('GET', $link->getHref());
        return $this->stateFactory->createState(
            'ChangeHistoryState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Read the child person data from this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\PersonState|null
     */
    public function readChild(StateTransitionOption $option = null)
    {
        $relationship = $this->getRelationship();
        if ($relationship == null) {
            return null;
        }

        $child = $relationship->getChild();
        if ($child == null || $child->getResource() == null) {
            return null;
        }

        $request = $this->createAuthenticatedRequest('GET', $child->getResource());
        return $this->stateFactory->createState(
            'PersonState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Read the father person data from this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return PersonState|null
     */
    public function readFather(StateTransitionOption $option = null)
    {
        $relationship = $this->getRelationship();
        if ($relationship == null) {
            return null;
        }

        $father = $relationship->getFather();
        if ($father == null || $father->getResource() == null) {
            return null;
        }

        $request = $this->createAuthenticatedRequest('GET', $father->getResource());
        return $this->stateFactory->createState(
            'PersonState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Update the father on this relationship using a PersonState
     *
     * @param \Gedcomx\Rs\Client\PersonState                   $father
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateFatherWithPersonState(PersonState $father, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateFather', array($father->getResourceReference()), func_get_args());
    }

    /**
     * Update the father on this relationship with a ResourceReference
     *
     * @param \Gedcomx\Common\ResourceReference                $father
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChildAndParentsRelationshipState
     */
    public function updateFather(ResourceReference $father, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setFather($father);
        $fsp = new FamilySearchPlatform();
        $fsp->addChildAndParentsRelationship($relationship);
        $request = $this->createAuthenticatedRequest('POST', $this->getSelfUri(), [], null, $fsp->toJson());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Remove the father from this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState|null
     */
    public function deleteFather(StateTransitionOption $option = null)
    {
        $link = $this->getLink(Rel::FATHER_ROLE);
        if ($link == null || $link->getHref() == null) {
            return null;
        }

        $request = $this->createAuthenticatedRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Read the mother person data from this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return PersonState|null
     */
    public function readMother(StateTransitionOption $option = null)
    {
        $relationship = $this->getRelationship();
        if ($relationship == null) {
            return null;
        }

        $mother = $relationship->getMother();
        if ($mother == null || $mother->getResource() == null) {
            return null;
        }

        $request = $this->createAuthenticatedRequest('GET', $mother->getResource());
        return $this->stateFactory->createState(
            'PersonState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Update the mother on this relationship with a PersonState
     *
     * @param \Gedcomx\Rs\Client\PersonState                   $mother
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    public function updateMotherWithPersonState(PersonState $mother, StateTransitionOption $option = null)
    {
        return $this->passOptionsTo('updateMother', array($mother->getResourceReference()), func_get_args());
    }

    /**
     * Update the mother on this relationship with a ResourceReference
     *
     * @param \Gedcomx\Common\ResourceReference                $mother
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Extensions\FamilySearch\Rs\Client\FamilyTree\ChildAndParentsRelationshipState
     */
    public function updateMother(ResourceReference $mother, StateTransitionOption $option = null)
    {
        $relationship = $this->createEmptySelf();
        $relationship->setMother($mother);
        $fsp = new FamilySearchPlatform();
        $fsp->addChildAndParentsRelationship($relationship);
        $request = $this->createAuthenticatedRequest('POST', $this->getSelfUri(), FamilySearchRequest::getMediaTypes(), null, $fsp->toJson());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Remove the mother from this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState|null
     */
    public function deleteMother(StateTransitionOption $option = null)
    {
        $link = $this->getLink(Rel::MOTHER_ROLE);
        if ($link == null || $link->getHref() == null) {
            return null;
        }

        $request = $this->createAuthenticatedRequest('DELETE', $link->getHref());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken);
    }

    /**
     * Restore a previously deleted relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return ChildAndParentsRelationshipState|null
     */
    public function restore(StateTransitionOption $option = null)
    {
        $link = $this->getLink(Rel::RESTORE);
        if ($link == null || $link->getHref() == null) {
            return null;
        }

        $request = $this->createAuthenticatedRequest('POST', $link->getHref());
        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Update a relationship passing in a Rel link to specify what needs to be updated.
     *
     * @param \Gedcomx\Extensions\FamilySearch\Platform\Tree\ChildAndParentsRelationship $relationship
     * @param string                                                                     $rel
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption                           $option,...
     *
     * @return ChildAndParentsRelationshipState
     */
    protected function updateRelationship(ChildAndParentsRelationship $relationship, $rel, StateTransitionOption $option = null)
    {
        $target = $this->getSelfUri();
        $link = $this->getLink($rel);
        if ($link != null && $link->getHref() != null) {
            $target = $link->getHref();
        }

        $gx = new FamilySearchPlatform();
        $gx->setChildAndParentsRelationships(array($relationship));
        $request = $this->createAuthenticatedRequest('POST', $target, FamilySearchRequest::getMediaTypes(), null, $gx->toJson());

        return $this->stateFactory->createState(
            'ChildAndParentsRelationshipState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

    /**
     * Read the list of sources associated with this relationship
     *
     * @param \Gedcomx\Rs\Client\Options\StateTransitionOption $option,...
     *
     * @return \Gedcomx\Rs\Client\SourceDescriptionState|null
     */
    public function readSources(StateTransitionOption $option = null)
    {
        $link = $this->getLink(Rel::SOURCE_DESCRIPTIONS);
        if ($link == null || $link->getHref() == null) {
            return null;
        }

        $request = $this->createAuthenticatedGedcomxRequest('GET', $link->getHref(), FamilySearchRequest::getMediaTypes());
        return $this->stateFactory->createState(
            'SourceDescriptionState',
            $this->client,
            $request,
            $this->passOptionsTo('invoke', array($request), func_get_args()),
            $this->accessToken
        );
    }

}
gedcomx-php-client API documentation generated by ApiGen