Issues (384)

src/Parser/Sour/Repo.php (1 issue)

Labels
Severity
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\Sour;
16
17
class Repo extends \Gedcom\Parser\Component
18
{
19
    public static function parse(\Gedcom\Parser $parser)
20
    {
21
        $repo = new \Gedcom\Record\Sour\Repo();
22
        $record = $parser->getCurrentLineRecord();
23
        $depth = (int) $record[0];
24
        if (isset($record[2])) {
25
            $_repo = $parser->normalizeIdentifier($record[2]);
26
            $repo->setRepo($_repo);
0 ignored issues
show
The method setRepo() does not exist on Gedcom\Record\Sour\Repo. 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

26
            $repo->/** @scrutinizer ignore-call */ 
27
                   setRepo($_repo);
Loading history...
27
        }
28
29
        $parser->forward();
30
31
        while (!$parser->eof()) {
32
            $record = $parser->getCurrentLineRecord();
33
            $recordType = strtoupper(trim($record[1]));
34
            $currentDepth = (int) $record[0];
35
36
            if ($currentDepth <= $depth) {
37
                $parser->back();
38
                break;
39
            }
40
41
            switch ($recordType) {
42
                case 'NOTE':
43
                    $repo->addNote(\Gedcom\Parser\NoteRef::parse($parser));
44
                    break;
45
                case 'CALN':
46
                    $repo->addCaln(\Gedcom\Parser\Sour\Repo\Caln::parse($parser));
47
                    break;
48
                default:
49
                    $parser->logUnhandledRecord(self::class.' @ '.__LINE__);
50
            }
51
52
            $parser->forward();
53
        }
54
55
        return $repo;
56
    }
57
}
58