1 | <?php declare(strict_types=1); |
||
20 | abstract class XmlAbstract extends StandardAbstract |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * Name of the node containing all the feed's items |
||
25 | */ |
||
26 | const ITEM_NODE = 'item'; |
||
27 | |||
28 | /** |
||
29 | * This is for XML Standards |
||
30 | */ |
||
31 | const SYNTAX_FORMAT = 'Xml'; |
||
32 | |||
33 | /** |
||
34 | * RuleSet used to parse the feed's main node |
||
35 | * @var \FeedIo\RuleSet |
||
36 | */ |
||
37 | protected $feedRuleSet; |
||
38 | |||
39 | /** |
||
40 | * @var \FeedIo\RuleSet |
||
41 | */ |
||
42 | protected $itemRuleSet; |
||
43 | |||
44 | /** |
||
45 | * Formats the document according to the standard's specification |
||
46 | * @param \DOMDocument $document |
||
47 | * @return \DOMDocument |
||
48 | */ |
||
49 | abstract public function format(\DOMDocument $document) : \DOMDocument; |
||
50 | |||
51 | /** |
||
52 | * @param \DOMDocument $document |
||
53 | * @return \DomElement |
||
54 | */ |
||
55 | abstract public function getMainElement(\DOMDocument $document) : \DOMElement; |
||
56 | |||
57 | /** |
||
58 | * Builds and returns a rule set to parse the root node |
||
59 | * @return \FeedIo\RuleSet |
||
60 | */ |
||
61 | abstract public function buildFeedRuleSet() : RuleSet; |
||
62 | |||
63 | /** |
||
64 | * Builds and returns a rule set to parse an item |
||
65 | * @return \FeedIo\RuleSet |
||
66 | */ |
||
67 | abstract public function buildItemRuleSet() : RuleSet; |
||
68 | |||
69 | /** |
||
70 | * @return string |
||
71 | */ |
||
72 | 16 | public function getItemNodeName() : string |
|
76 | |||
77 | /** |
||
78 | * @return FormatterInterface |
||
79 | */ |
||
80 | 1 | public function getFormatter() : FormatterInterface |
|
81 | { |
||
82 | 1 | return new XmlFormatter($this); |
|
83 | } |
||
84 | |||
85 | /** |
||
86 | * Returns the RuleSet used to parse the feed's main node |
||
87 | * @return \FeedIo\RuleSet |
||
88 | */ |
||
89 | 17 | public function getFeedRuleSet() : RuleSet |
|
90 | { |
||
91 | 17 | if (is_null($this->feedRuleSet)) { |
|
92 | 17 | $this->feedRuleSet = $this->buildFeedRuleSet(); |
|
93 | } |
||
94 | |||
95 | 17 | return $this->feedRuleSet; |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * @return \FeedIo\RuleSet |
||
100 | */ |
||
101 | 15 | public function getItemRuleSet() : RuleSet |
|
102 | { |
||
103 | 15 | if (is_null($this->itemRuleSet)) { |
|
104 | 15 | $this->itemRuleSet = $this->buildItemRuleSet(); |
|
105 | } |
||
106 | |||
107 | 15 | return $this->itemRuleSet; |
|
108 | } |
||
109 | |||
110 | /** |
||
111 | * @param string $tagName |
||
112 | * @return ModifiedSince |
||
113 | */ |
||
114 | 19 | public function getModifiedSinceRule(string $tagName) : ModifiedSince |
|
122 | |||
123 | /** |
||
124 | * @return RuleSet |
||
125 | */ |
||
126 | 19 | protected function buildBaseRuleSet() : RuleSet |
|
133 | } |
||
134 |