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

Html::__toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 5
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Serialize a DOM into an Html 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 Html 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 1
    public function __construct(\DOMNode $node) {
23 1
      $this->_node = $node;
24 1
    }
25
26
    /**
27
     * @return string
28
     */
29 1
    public function __toString(): string {
30 1
      return $this->_node instanceof \DOMDocument
31 1
        ? $this->_node->saveHTML()
32 1
        : $this->_node->ownerDocument->saveHTML($this->_node);
33
    }
34
  }
35
}