Completed
Push — master ( fd90eb...52b814 )
by Stefan
04:00
created

ShipFrom::toNode()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 23
Code Lines 12

Duplication

Lines 23
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 6.3183

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 23
loc 23
ccs 10
cts 16
cp 0.625
rs 8.5906
cc 5
eloc 12
nc 16
nop 1
crap 6.3183
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
class ShipFrom extends Shipper implements NodeInterface
10
{
11
    /**
12
     * @param null|DOMDocument $document
13
     *
14
     * @return DOMElement
15
     */
16 1 View Code Duplication
    public function toNode(DOMDocument $document = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18 1
        if (null === $document) {
19
            $document = new DOMDocument();
20
        }
21
22 1
        $node = $document->createElement('ShipFrom');
23
24 1
        if ($this->getCompanyName()) {
25
            $node->appendChild($document->createElement('CompanyName', $this->getCompanyName()));
26
        }
27
28 1
        if ($this->getAttentionName()) {
29
            $node->appendChild($document->createElement('AttentionName', $this->getAttentionName()));
30
        }
31
32 1
        $address = $this->getAddress();
33 1
        if (isset($address)) {
34 1
            $node->appendChild($address->toNode($document));
35 1
        }
36
37 1
        return $node;
38
    }
39
}
40