Completed
Push — master ( e74d94...4f7e5e )
by Thomas
03:05
created

Xml   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 22
loc 22
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A __toString() 5 5 2

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
 * Serialize a DOM into an Xml string.
4
 *
5
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
6
 * @copyright Copyright (c) 2009-2017 FluentDOM Contributors
7
 */
8
9
namespace FluentDOM\Serializer {
10
11
  use FluentDOM\Utility\StringCastable;
12
13 View Code Duplication
  class Xml implements StringCastable {
1 ignored issue
show
Duplication introduced by
This class 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...
14
    /**
15
     * @var \DOMNode
16
     */
17
    protected $_node;
18
19
    /**
20
     * @param \DOMNode $node
21
     */
22 2
    public function __construct(\DOMNode $node) {
23 2
      $this->_node = $node;
24 2
    }
25
26
    /**
27
     * @return string
28
     */
29 2
    public function __toString(): string {
30 2
      return $this->_node instanceof \DOMDocument
31 2
        ? $this->_node->saveXML()
32 2
        : $this->_node->ownerDocument->saveXML($this->_node);
33
    }
34
  }
35
}