Completed
Pull Request — master (#273)
by
unknown
08:25
created

SitemapNamespace   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A overrideNamespaces() 0 4 1
A generateNamespaces() 0 8 2
A setDefault() 0 7 1
1
<?php
2
3
namespace Spatie\Sitemap;
4
5
6
class SitemapNamespace
7
{
8
    public static $namespaces = [
9
        'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
10
        'xmlns:xhtml' => 'http://www.w3.org/1999/xhtml',
11
    ];
12
13
    public static function overrideNamespaces($namespaces = [])
14
    {
15
        self::$namespaces = array_merge(self::$namespaces, $namespaces);
16
    }
17
18
    public static function generateNamespaces()
19
    {
20
        $result = '';
21
        foreach (self::$namespaces as $key => $value) {
22
            $result .= ' '.$key.'="'.$value.'"';
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