Passed
Branch master (6a7148)
by Curtis
01:48
created

Data   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
B parse() 0 40 6
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
 * @package         php-gedcom
11
 * @license         MIT
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace PhpGedcom\Parser\Head\Sour;
16
17
/**
18
 *
19
 *
20
 */
21
class Data extends \PhpGedcom\Parser\Component
22
{
23
24
    /**
25
     *
26
     *
27
     */
28
    public static function parse(\PhpGedcom\Parser $parser)
29
    {
30
        $record = $parser->getCurrentLineRecord();
31
        $depth = (int)$record[0];
32
        if(isset($record[2])){
33
          $data = new \PhpGedcom\Record\Head\Sour\Data();
34
          $data->setData(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setData() does not exist on PhpGedcom\Record\Head\Sour\Data. 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

34
          $data->/** @scrutinizer ignore-call */ 
35
                 setData(trim($record[2]));
Loading history...
35
        }
36
        else{
37
           $parser->skipToNextLevel($depth);
38
           return null;
39
        }
40
41
        $parser->forward();
42
43
        while (!$parser->eof()) {
44
            $record = $parser->getCurrentLineRecord();
45
            $recordType = strtoupper(trim($record[1]));
46
            $currentDepth = (int)$record[0];
47
48
            if ($currentDepth <= $depth) {
49
                $parser->back();
50
                break;
51
            }
52
53
            switch ($recordType) {
54
                case 'DATE':
55
                    $data->setDate(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setDate() does not exist on PhpGedcom\Record\Head\Sour\Data. 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

55
                    $data->/** @scrutinizer ignore-call */ 
56
                           setDate(trim($record[2]));
Loading history...
56
                    break;
57
                case 'COPR':
58
                    $data->setCopr(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setCopr() does not exist on PhpGedcom\Record\Head\Sour\Data. 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

58
                    $data->/** @scrutinizer ignore-call */ 
59
                           setCopr(trim($record[2]));
Loading history...
59
                    break;
60
                default:
61
                    $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
62
            }
63
64
            $parser->forward();
65
        }
66
67
        return $data;
68
    }
69
}
70