FeedBuilder::channel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PODEntender\Domain\Model\Feed;
4
5
class FeedBuilder
6
{
7
    /** @var ChannelBuilder[] */
8
    private $channels = [];
9
10 4
    public function channel(): ChannelBuilder
11
    {
12 4
        $channelBuilder = new ChannelBuilder($this);
13 4
        $this->channels[] = $channelBuilder;
14 4
        return $channelBuilder;
15
    }
16
17 4
    public function toXml(): string
18
    {
19 4
        $dom = new \DOMDocument('1.0', 'utf-8');
20 4
        $rss = $dom->appendChild($dom->createElement('rss'));
21 4
        $rss->setAttribute('xmlns:googleplay', 'http://www.google.com/schemas/play-podcasts/1.0');
22 4
        $rss->setAttribute('xmlns:itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
23 4
        $rss->setAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
24 4
        $rss->setAttribute('version', '2.0');
25
26 4
        foreach ($this->channels as $channel) {
27 4
            $rss->appendChild($channel->toDOMElement($dom));
28
        }
29
30 4
        $dom->formatOutput = true;
31
32 4
        return $dom->saveXML();
33
    }
34
}
35