PlainTextSitemapRender   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 34
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 5 1
A end() 0 4 1
A url() 0 9 1
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Component\Sitemap\Render;
11
12
use GpsLab\Component\Sitemap\Url\Url;
13
14
class PlainTextSitemapRender implements SitemapRender
15
{
16
    /**
17
     * @return string
18
     */
19 9
    public function start()
20
    {
21 9
        return '<?xml version="1.0" encoding="utf-8"?>'.PHP_EOL.
22 9
            '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
23
    }
24
25
    /**
26
     * @return string
27
     */
28 9
    public function end()
29
    {
30 9
        return '</urlset>'.PHP_EOL;
31
    }
32
33
    /**
34
     * @param Url $url
35
     *
36
     * @return string
37
     */
38 5
    public function url(Url $url)
39
    {
40
        return '<url>'.
41 5
            '<loc>'.htmlspecialchars($url->getLoc()).'</loc>'.
42 5
            '<lastmod>'.$url->getLastMod()->format('c').'</lastmod>'.
43 5
            '<changefreq>'.$url->getChangeFreq().'</changefreq>'.
44 5
            '<priority>'.$url->getPriority().'</priority>'.
45 5
        '</url>';
46
    }
47
}
48