Plac   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
B convert() 0 39 9
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          Xiang Ming <[email protected]>
9
 * @copyright       Copyright (c) 2010-2013, Xiang Ming
10
 * @license         MIT
11
 *
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace PhpGedcom\Writer\Indi\Even;
16
17
class Plac
18
{
19
    /**
20
     * @param \PhpGedcom\Record\Indi\Even\Plac $plac
21
     * @param int                              $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\PhpGedcom\Record\Indi\Even\Plac &$plac, $level = 0)
26
    {
27
        $output = '';
28
29
        // $plac
30
        $_plac = $plac->getPlac();
31
        if (!empty($_plac)) {
32
            $output .= $level.' PLAC '.$_plac."\n";
33
        } else {
34
            $output .= $level." PLAC\n";
35
        }
36
37
        // level up
38
        $level++;
39
40
        // $form
41
        $form = $plac->getForm();
42
        if (!empty($form)) {
43
            $output .= $level.' FORM '.$form."\n";
44
        }
45
46
        // $note -array
47
        $note = $plac->getNote();
48
        if ($note && count($note) > 0) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $note of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
49
            foreach ($note as $item) {
50
                $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level);
51
                $output .= $_convert;
52
            }
53
        }
54
        // $sour -array
55
        $sour = $plac->getSour();
56
        if ($sour && count($sour) > 0) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $sour of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
57
            foreach ($sour as $item) {
58
                $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level);
59
                $output .= $_convert;
60
            }
61
        }
62
63
        return $output;
64
    }
65
}
66