Code Duplication    Length = 14-14 lines in 2 locations

app/Query/QueryName.php 1 location

@@ 492-505 (lines=14) @@
489
490
		$list = [];
491
		$rows = Database::prepare($sql)->execute($args)->fetchAll();
492
		foreach ($rows as $row) {
493
			$person = Individual::getInstance($row->xref, $tree, $row->gedcom);
494
			// The name from the database may be private - check the filtered list...
495
			foreach ($person->getAllNames() as $n => $name) {
496
				if ($name['fullNN'] == $row->n_full) {
497
					$person->setPrimaryName($n);
498
					// We need to clone $person, as we may have multiple references to the
499
					// same person in this list, and the "primary name" would otherwise
500
					// be shared amongst all of them.
501
					$list[] = clone $person;
502
					break;
503
				}
504
			}
505
		}
506
507
		return $list;
508
	}

app/Functions/FunctionsDb.php 1 location

@@ 224-237 (lines=14) @@
221
		$sql .= ")";
222
		$list = [];
223
		$rows = Database::prepare($sql)->execute($args)->fetchAll();
224
		foreach ($rows as $row) {
225
			$indi = Individual::getInstance($row->xref, Tree::findById($row->gedcom_id), $row->gedcom);
226
			foreach ($indi->getAllNames() as $num => $name) {
227
				if ($name['fullNN'] === $row->n_full) {
228
					$indi->setPrimaryName($num);
229
					// We need to clone $indi, as we may have multiple references to the
230
					// same person in this list, and the "primary name" would otherwise
231
					// be shared amongst all of them.
232
					$list[] = clone $indi;
233
					// Only need to match an individual on one name
234
					break;
235
				}
236
			}
237
		}
238
		$list = array_filter($list, function (Individual $x) {
239
			return $x->canShowName();
240
		});