Completed
Push — master ( da2f6e...d3b8cb )
by Kamil
20:06
created

Sitemap::getUrls()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Sylius\Bundle\CoreBundle\Sitemap\Model;
13
14
use Sylius\Bundle\CoreBundle\Sitemap\Exception\SitemapUrlNotFoundException;
15
16
/**
17
 * @author Arkadiusz Krakowiak <[email protected]>
18
 */
19
class Sitemap implements SitemapInterface
20
{
21
    /**
22
     * @var array
23
     */
24
    private $urls = [];
25
26
    /**
27
     * @var string
28
     */
29
    private $localization;
30
31
    /**
32
     * @var \DateTime
33
     */
34
    private $lastModification;
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function setUrls(array $urls)
40
    {
41
        $this->urls = $urls;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function getUrls()
48
    {
49
        return $this->urls;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function addUrl(SitemapUrlInterface $url)
56
    {
57
        $this->urls[] = $url;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function removeUrl(SitemapUrlInterface $url)
64
    {
65
        $key = array_search($url, $this->urls, true);
66
        if (false === $key) {
67
            throw new SitemapUrlNotFoundException($url);
68
        }
69
70
        unset($this->urls[$key]);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function setLocalization($localization)
77
    {
78
        $this->localization = $localization;
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function getLocalization()
85
    {
86
        return $this->localization;
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function setLastModification(\DateTime $lastModification)
93
    {
94
        $this->lastModification = $lastModification;
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function getLastModification()
101
    {
102
        return $this->lastModification;
103
    }
104
}
105