Completed
Pull Request — master (#273)
by
unknown
07:23 queued 06:19
created

SitemapNamespace::generateNamespaces()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Spatie\Sitemap;
4
5
class SitemapNamespace
6
{
7
    public static $namespaces = [
8
        'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
9
        'xmlns:xhtml' => 'http://www.w3.org/1999/xhtml',
10
    ];
11
12
    public static function overrideNamespaces($namespaces = [])
13
    {
14
        self::$namespaces = array_merge(self::$namespaces, $namespaces);
15
    }
16
17
    public static function generateNamespaces()
18
    {
19
        $result = '';
20
        foreach (self::$namespaces as $key => $value) {
21
            $result .= ' '.$key.'="'.$value.'"';
22
        }
23
24
        return $result;
25
    }
26
27
    public static function setDefault()
28
    {
29
        self::$namespaces = [
30
            'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
31
            'xmlns:xhtml' => 'http://www.w3.org/1999/xhtml',
32
        ];
33
    }
34
}
35