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

ShipFrom   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 74.19 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 62.5%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 2
dl 23
loc 31
ccs 10
cts 16
cp 0.625
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B toNode() 23 23 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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