app/Module/BatchUpdate/BatchUpdateMarriedNamesPlugin.php
private function surnamesToAdd(GedcomRecord $record): array
    {
        $gedcom = $record->gedcom();
        $tree   = $record->tree();

        $wife_surnames    = $this->surnames($record);
        $husb_surnames    = [];
        $missing_surnames = [];

        preg_match_all('/^1 FAMS @(.+)@/m', $gedcom, $fmatch);

        foreach ($fmatch[1] as $famid) {
            $family = Family::getInstance($famid, $tree);
            $famrec = $family->gedcom();

            if (preg_match('/^1 MARR/m', $famrec) && preg_match('/^1 HUSB @(.+)@/m', $famrec, $hmatch)) {
                $spouse = Individual::getInstance($hmatch[1], $tree);

                if ($spouse instanceof Individual) {
                    $husb_surnames = array_unique(array_merge($husb_surnames, $this->surnames($spouse)));
                }
            }
        }

        foreach ($husb_surnames as $husb_surname) {
            if (!in_array($husb_surname, $wife_surnames, true)) {
                $missing_surnames[] = $husb_surname;
            }
        }

        return $missing_surnames;
    }
private function surnamesToAdd(GedcomRecord $record): array
    {
        $gedcom = $record->gedcom();
        $tree   = $record->tree();

        $wife_surnames    = $this->surnames($record);
        $husb_surnames    = [];
        $missing_surnames = [];

        preg_match_all('/^1 FAMS @(.+)@/m', $gedcom, $fmatch);

        foreach ($fmatch[1] as $famid) {
            $family = Family::getInstance($famid, $tree);
            $famrec = $family->gedcom();

            if (preg_match('/^1 MARR/m', $famrec) && preg_match('/^1 HUSB @(.+)@/m', $famrec, $hmatch)) {
                $spouse = Individual::getInstance($hmatch[1], $tree);

                if ($spouse instanceof Individual) {
                    $husb_surnames = array_unique(array_merge($husb_surnames, $this->surnames($spouse)));
                }
            }
        }

        foreach ($husb_surnames as $husb_surname) {
            if (!in_array($husb_surname, $wife_surnames, true)) {
                $missing_surnames[] = $husb_surname;
            }
        }

        return $missing_surnames;
    }
private function surnamesToAdd ( GedcomRecord $ record ) : array { $ gedcom = $ record -> gedcom ( ) ; $ tree = $ record -> tree ( ) ; $ wife_surnames = $ this -> surnames ( $ record ) ; $ husb_surnames = [ ] ; $ missing_surnames = [ ] ; preg_match_all ( '/^1 FAMS @(.+)@/m' , $ gedcom , $ fmatch ) ; foreach ( $ fmatch [ 1 ] as $ famid ) { $ family = Family :: getInstance ( $ famid , $ tree ) ; $ famrec = $ family -> gedcom ( ) ; if ( preg_match ( '/^1 MARR/m' , $ famrec ) && preg_match ( '/^1 HUSB @(.+)@/m' , $ famrec , $ hmatch ) ) { $ spouse = Individual :: getInstance ( $ hmatch [ 1 ] , $ tree ) ; if ( $ spouse instanceof Individual ) { $ husb_surnames = array_unique ( array_merge ( $ husb_surnames , $ this -> surnames ( $ spouse ) ) ) ; } } } foreach ( $ husb_surnames as $ husb_surname ) { if ( ! in_array ( $ husb_surname , $ wife_surnames , true ) ) { $ missing_surnames [ ] = $ husb_surname ; } } return $ missing_surnames ; }
Generate a list of married surnames that are not already present.

@param GedcomRecord $record

@return string[]
Generate a list of married surnames that are not already present .