FeedBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 15
dl 0
loc 28
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toXml() 0 16 2
A channel() 0 5 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