Completed
Push — master ( 1d52ac...913a22 )
by Joseph
14:38
created

Node   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toString() 0 4 1
A attr() 0 12 3
1
<?php
2
3
namespace Jclyons52\PHPQuery;
4
5
class Node
6
{
7
    public $node;
8
9
    public function __construct(\DOMNode $node)
10
    {
11
        $this->node = $node;
12
    }
13
14
    public function toString()
15
    {
16
        return $this->node->ownerDocument->saveHTML($this->node);
17
    }
18
19
    public function attr($name, $value = null)
20
    {
21
        if (!($this->node instanceof \DOMElement)) {
22
            throw new \Exception('dom node is not of type element');
23
        }
24
25
        if ($value) {
26
            $this->node->setAttribute($name, $value);
27
        }
28
        
29
        return $this->node->getAttribute($name);
30
    }
31
}
32