Name   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 17
eloc 60
dl 0
loc 77
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C parse() 0 75 17
1
<?php
2
/**
3
 * php-gedcom.
4
 *
5
 * php-gedcom is a library for parsing, manipulating, importing and exporting
6
 * GEDCOM 5.5 files in PHP 5.3+.
7
 *
8
 * @author          Kristopher Wilson <[email protected]>
9
 * @copyright       Copyright (c) 2010-2013, Kristopher Wilson
10
 * @license         MIT
11
 *
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace Gedcom\Parser\Indi;
16
17
class Name extends \Gedcom\Parser\Component
18
{
19
    public static function parse(\Gedcom\Parser $parser)
20
    {
21
        $record = $parser->getCurrentLineRecord();
22
        $depth = (int) $record[0];
23
        if (isset($record[2])) {
24
            $name = new \Gedcom\Record\Indi\Name();
25
            $name->setName(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setName() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            $name->/** @scrutinizer ignore-call */ 
26
                   setName(trim($record[2]));
Loading history...
26
        } else {
27
            $parser->skipToNextLevel($depth);
28
29
            return null;
30
        }
31
32
        $parser->forward();
33
34
        while (!$parser->eof()) {
35
            $record = $parser->getCurrentLineRecord();
36
            $recordType = strtoupper(trim($record[1]));
37
            $currentDepth = (int) $record[0];
38
39
            if ($currentDepth <= $depth) {
40
                $parser->back();
41
                break;
42
            }
43
44
            if (!isset($record[2])) {
45
                $record[2] = '';
46
            }
47
48
            switch ($recordType) {
49
                case 'TYPE':
50
                    $name->setType(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setType() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
                    $name->/** @scrutinizer ignore-call */ 
51
                           setType(trim($record[2]));
Loading history...
51
                    break;
52
                case 'NPFX':
53
                    $name->setNpfx(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setNpfx() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
                    $name->/** @scrutinizer ignore-call */ 
54
                           setNpfx(trim($record[2]));
Loading history...
54
                    break;
55
                case 'GIVN':
56
                    $name->setGivn(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setGivn() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
                    $name->/** @scrutinizer ignore-call */ 
57
                           setGivn(trim($record[2]));
Loading history...
57
                    break;
58
                case 'NICK':
59
                    $name->setNick(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setNick() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

59
                    $name->/** @scrutinizer ignore-call */ 
60
                           setNick(trim($record[2]));
Loading history...
60
                    break;
61
                case 'SPFX':
62
                    $name->setSpfx(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setSpfx() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

62
                    $name->/** @scrutinizer ignore-call */ 
63
                           setSpfx(trim($record[2]));
Loading history...
63
                    break;
64
                case 'SURN':
65
                    $name->setSurn(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setSurn() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
                    $name->/** @scrutinizer ignore-call */ 
66
                           setSurn(trim($record[2]));
Loading history...
66
                    break;
67
                case 'NSFX':
68
                    $name->setNsfx(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setNsfx() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
                    $name->/** @scrutinizer ignore-call */ 
69
                           setNsfx(trim($record[2]));
Loading history...
69
                    break;
70
                case 'SOUR':
71
                    $sour = \Gedcom\Parser\SourRef::parse($parser);
72
                    $name->addSour($sour);
73
                    break;
74
                case 'NOTE':
75
                    $note = \Gedcom\Parser\NoteRef::parse($parser);
76
                    if ($note) {
77
                        $name->addNote($note);
78
                    }
79
                    break;
80
                case 'FONE':
81
                    $name->setFone(\Parser\Indi\Name\Fone::parse($parser));
0 ignored issues
show
Bug introduced by
The type Parser\Indi\Name\Fone was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The method setFone() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
                    $name->/** @scrutinizer ignore-call */ 
82
                           setFone(\Parser\Indi\Name\Fone::parse($parser));
Loading history...
82
                    break;
83
                case 'ROMN':
84
                    $name->setRomn(\Parser\Indi\Name\Romn::parse($parser));
0 ignored issues
show
Bug introduced by
The method setRomn() does not exist on Gedcom\Record\Indi\Name. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

84
                    $name->/** @scrutinizer ignore-call */ 
85
                           setRomn(\Parser\Indi\Name\Romn::parse($parser));
Loading history...
Bug introduced by
The type Parser\Indi\Name\Romn was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
85
                    break;
86
                default:
87
                    $parser->logUnhandledRecord(self::class.' @ '.__LINE__);
88
            }
89
90
            $parser->forward();
91
        }
92
93
        return $name;
94
    }
95
}
96