Completed
Push — master ( 0d3592...0bb29a )
by Peter
06:28
created

PlainTextSitemapIndexRender   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 33
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 5 1
A end() 0 4 1
A sitemap() 0 7 2
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
class PlainTextSitemapIndexRender implements SitemapIndexRender
13
{
14
    /**
15
     * @return string
16
     */
17
    public function start()
18
    {
19
        return '<?xml version="1.0" encoding="utf-8"?>'.PHP_EOL.
20
            '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
21
    }
22
23
    /**
24
     * @return string
25
     */
26
    public function end()
27
    {
28
        return '</sitemapindex>'.PHP_EOL;
29
    }
30
31
    /**
32
     * @param string                  $url
33
     * @param \DateTimeImmutable|null $last_mod
34
     *
35
     * @return string
36
     */
37
    public function sitemap($url, \DateTimeImmutable $last_mod = null)
38
    {
39
        return '<sitemap>'.
40
            '<loc>'.$url.'</loc>'.
41
            ($last_mod ? sprintf('<lastmod>%s</lastmod>', $last_mod->format('c')) : '').
42
        '</sitemap>';
43
    }
44
}
45