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

Addr::convert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 3
dl 0
loc 20
rs 9.8666
c 0
b 0
f 0
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\Writer;
16
17
/**
18
 *
19
 */
20
class Addr
21
{
22
    /**
23
     * @param \PhpGedcom\Record\Addr $addr
24
     * @param string $format
25
     * @param int $level
26
     * @return string
27
     */
28
    public static function convert(\PhpGedcom\Record\Addr &$addr, $format = self::GEDCOM55, $level = 1)
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

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

28
    public static function convert(\PhpGedcom\Record\Addr &$addr, /** @scrutinizer ignore-unused */ $format = self::GEDCOM55, $level = 1)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Bug introduced by
The constant PhpGedcom\Writer\Addr::GEDCOM55 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
29
    {
30
        $addrs = explode("\n", $addr->getAddr());
31
        
32
        $output = "{$level} ADDR " . $addrs[0] . "\n";
33
        
34
        array_shift($addrs);
35
        
36
        foreach ($addrs as $cont) {
37
            $output .= ($level+1) . " CONT " . $cont . "\n";
38
        }
39
40
        $output .= ($level+1) . " ADR1 " . $addr->adr1 . "\n" .
0 ignored issues
show
Bug introduced by
The property adr1 is declared protected in PhpGedcom\Record\Addr and cannot be accessed from this context.
Loading history...
41
            ($level+1) . " ADR2 " . $addr->getAdr2() . "\n" .
42
            ($level+1) . " CITY " . $addr->getCity() . "\n" .
43
            ($level+1) . " STAE " . $addr->getStae() . "\n" .
44
            ($level+1) . " POST " . $addr->getPost() . "\n" .
45
            ($level+1) . " CTRY " . $addr->getCtry() . "\n";
46
        
47
        return $output;
48
    }
49
}
50