Completed
Pull Request — master (#273)
by
unknown
01:20
created

SitemapNamespace::generateNamespaces()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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