Plac   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

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

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 Gedcom\Writer\Indi\Even;
16
17
class Plac
18
{
19
    /**
20
     * @param int $level
21
     *
22
     * @return string
23
     */
24
    public static function convert(\Gedcom\Record\Indi\Even\Plac &$plac, $level = 0)
25
    {
26
        $output = '';
27
28
        // $plac
29
        $_plac = $plac->getPlac();
30
        if (!empty($_plac)) {
31
            $output .= $level.' PLAC '.$_plac."\n";
32
        } else {
33
            $output .= $level." PLAC\n";
34
        }
35
36
        // level up
37
        $level++;
38
39
        // $form
40
        $form = $plac->getForm();
41
        if (!empty($form)) {
42
            $output .= $level.' FORM '.$form."\n";
43
        }
44
45
        // $note -array
46
        $note = $plac->getNote();
47
        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...
48
            foreach ($note as $item) {
49
                $_convert = \Gedcom\Writer\NoteRef::convert($item, $level);
50
                $output .= $_convert;
51
            }
52
        }
53
        // $sour -array
54
        $sour = $plac->getSour();
55
        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...
56
            foreach ($sour as $item) {
57
                $_convert = \Gedcom\Writer\SourRef::convert($item, $level);
58
                $output .= $_convert;
59
            }
60
        }
61
62
        return $output;
63
    }
64
}
65