File GedcomRecord.php
has 638 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* webtrees: online genealogy
* Copyright (C) 2023 webtrees development team
GedcomRecord
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
class GedcomRecord
{
public const RECORD_TYPE = 'UNKNOWN';
protected const ROUTE_NAME = GedcomRecordPage::class;
Function extractNamesFromFacts
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
protected function extractNamesFromFacts(int $level, string $fact_type, Collection $facts): void
{
$sublevel = $level + 1;
$subsublevel = $sublevel + 1;
foreach ($facts as $fact) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function updateFact
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function updateFact(string $fact_id, string $gedcom, bool $update_chan): void
{
// Not all record types allow a CHAN event.
$update_chan = $update_chan && in_array(static::RECORD_TYPE, Gedcom::RECORDS_WITH_CHAN, true);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method updateFact
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateFact(string $fact_id, string $gedcom, bool $update_chan): void
{
// Not all record types allow a CHAN event.
$update_chan = $update_chan && in_array(static::RECORD_TYPE, Gedcom::RECORDS_WITH_CHAN, true);
Function facts
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function facts(
array $filter = [],
bool $sort = false,
int $access_level = null,
bool $ignore_deleted = false
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method facts
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function facts(
array $filter = [],
bool $sort = false,
int $access_level = null,
bool $ignore_deleted = false
Function getSecondaryName
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function getSecondaryName(): int
{
if ($this->getSecondaryName === null) {
// Generally, the primary and secondary names are the same
$this->getSecondaryName = $this->getPrimaryName();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function canShowRecord
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function canShowRecord(int $access_level): bool
{
// This setting would better be called "$ENABLE_PRIVACY"
if (!$this->tree->getPreference('HIDE_LIVE_PEOPLE')) {
return true;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function parseFacts
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function parseFacts(): array
{
// Split the record into facts
if ($this->gedcom !== '') {
$gedcom_facts = preg_split('/\n(?=1)/', $this->gedcom);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseFacts
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function parseFacts(): array
{
// Split the record into facts
if ($this->gedcom !== '') {
$gedcom_facts = preg_split('/\n(?=1)/', $this->gedcom);
Method canShowRecord
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function canShowRecord(int $access_level): bool
{
// This setting would better be called "$ENABLE_PRIVACY"
if (!$this->tree->getPreference('HIDE_LIVE_PEOPLE')) {
return true;
Method updateRecord
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateRecord(string $gedcom, bool $update_chan): void
{
// Not all record types allow a CHAN event.
$update_chan = $update_chan && in_array(static::RECORD_TYPE, Gedcom::RECORDS_WITH_CHAN, true);
Function lastChangeTimestamp
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function lastChangeTimestamp(): TimestampInterface
{
$chan = $this->facts(['CHAN'])->first();
if ($chan instanceof Fact) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getPrimaryName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getPrimaryName(): int
{
static $language_script;
$language_script ??= I18N::locale()->script()->code();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function removeLinks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function removeLinks(string $xref, bool $update_chan): void
{
$value = '@' . $xref . '@';
foreach ($this->facts() as $fact) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getAllNames
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getAllNames(): array
{
if ($this->getAllNames === []) {
if ($this->canShowName()) {
// Ask the record to extract its names
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return $this->canShowByType($access_level);
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $individual_privacy[$this->xref()] >= $access_level;
Avoid too many return
statements within this method. Open
return true;
Function updateRecord
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function updateRecord(string $gedcom, bool $update_chan): void
{
// Not all record types allow a CHAN event.
$update_chan = $update_chan && in_array(static::RECORD_TYPE, Gedcom::RECORDS_WITH_CHAN, true);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getAllEventPlaces
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getAllEventPlaces(array $events): array
{
$places = [];
foreach ($this->facts($events) as $event) {
if (preg_match_all('/\n(?:2 PLAC|3 (?:ROMN|FONE|_HEB)) +(.+)/', $event->gedcom(), $ged_places)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"