YouTubeRule::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 9.3142
c 0
b 0
f 0
cc 2
eloc 11
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Kaloa\Renderer\Xml\Rule;
4
5
use Kaloa\Renderer\Xml\Rule\AbstractRule;
6
7
/**
8
 *
9
 */
10
final class YouTubeRule extends AbstractRule
11
{
12
    /**
13
     *
14
     */
15 1
    public function render()
16
    {
17 1
        foreach ($this->runXpathQuery('//youtube') as $node) {
18
            /* @var $node DOMElement */
19 1
            $parent = $node->parentNode;
20
21 1
            $fragment = $this->getDocument()->createDocumentFragment();
22
23 1
            $id = $node->getAttribute('id');
24
25
            $xml = <<<EOT
26
<div class="videoWrapper">
27
<iframe src="http://www.youtube.com/embed/$id" frameborder="0"></iframe>
28 1
</div>
29 1
EOT;
30
31 1
            $fragment->appendXML($xml);
32
33 1
            $parent->replaceChild($fragment, $node);
34 1
        }
35 1
    }
36
}
37