Total Complexity | 6 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class SitemapProvider |
||
10 | { |
||
11 | /** @var SitemapItems */ |
||
12 | private $items; |
||
13 | |||
14 | /** @var string - bvb: NewsArticle, will create a "sitemap_NewsArticle.xml" file */ |
||
15 | private $key; |
||
16 | |||
17 | public function __construct(string $key) |
||
18 | { |
||
19 | $this->key = $key; |
||
20 | $this->items = new SitemapItems(); |
||
21 | } |
||
22 | |||
23 | public function getItems(): SitemapItems |
||
24 | { |
||
25 | return $this->items; |
||
26 | } |
||
27 | |||
28 | public function getFilename(): string |
||
29 | { |
||
30 | try { |
||
31 | $suffix = (new \ReflectionClass($this->getKey()))->getShortName(); |
||
32 | } catch (\Exception $e) { |
||
33 | $namespaceParts = explode('\\', $this->getKey()); |
||
34 | $suffix = array_pop($namespaceParts); |
||
35 | } |
||
36 | |||
37 | return 'sitemap_' . $suffix; |
||
38 | } |
||
39 | |||
40 | public function getKey(): string |
||
41 | { |
||
42 | return $this->key; |
||
43 | } |
||
44 | |||
45 | public function createItem( |
||
52 | } |
||
53 | } |
||
54 |