1 | <?php |
||
27 | abstract class ParserAbstract |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * @var \Psr\Log\LoggerInterface |
||
32 | */ |
||
33 | protected $logger; |
||
34 | |||
35 | /** |
||
36 | * @var array[FilterInterface] |
||
37 | */ |
||
38 | protected $filters = array(); |
||
39 | |||
40 | /** |
||
41 | * @var StandardAbstract |
||
42 | */ |
||
43 | protected $standard; |
||
44 | |||
45 | /** |
||
46 | * @param StandardAbstract $standard |
||
47 | * @param LoggerInterface $logger |
||
48 | */ |
||
49 | 40 | public function __construct(StandardAbstract $standard, LoggerInterface $logger) |
|
54 | |||
55 | /** |
||
56 | * Tries to parse the document |
||
57 | * |
||
58 | * @param Document $document |
||
59 | * @param FeedInterface $feed |
||
60 | * @return \FeedIo\FeedInterface |
||
61 | * @throws \FeedIo\Parser\UnsupportedFormatException |
||
62 | */ |
||
63 | 12 | public function parse(Document $document, FeedInterface $feed) |
|
74 | |||
75 | /** |
||
76 | * This method is called by parse() if and only if the checkBodyStructure was successful |
||
77 | * |
||
78 | * @param Document $document |
||
79 | * @param FeedInterface $feed |
||
80 | * @return \FeedIo\FeedInterface |
||
81 | */ |
||
82 | abstract public function parseContent(Document $document, FeedInterface $feed); |
||
83 | |||
84 | /** |
||
85 | * @param Document $document |
||
86 | * @param array $mandatoryFields |
||
87 | * @return $this |
||
88 | * @throws MissingFieldsException |
||
89 | */ |
||
90 | abstract public function checkBodyStructure(Document $document, array $mandatoryFields); |
||
91 | |||
92 | /** |
||
93 | * @return StandardAbstract |
||
94 | */ |
||
95 | 25 | public function getStandard() |
|
99 | |||
100 | /** |
||
101 | * @param FeedInterface $feed |
||
102 | * @param NodeInterface $item |
||
103 | * @return $this |
||
104 | */ |
||
105 | 7 | public function addValidItem(FeedInterface $feed, NodeInterface $item) |
|
113 | |||
114 | /** |
||
115 | * @param ItemInterface $item |
||
116 | * @return bool |
||
117 | */ |
||
118 | 9 | public function isValid(ItemInterface $item) |
|
128 | |||
129 | /** |
||
130 | * @param FilterInterface $filter |
||
131 | * @return $this |
||
132 | */ |
||
133 | 5 | public function addFilter(FilterInterface $filter) |
|
139 | |||
140 | /** |
||
141 | * Reset filters |
||
142 | * @return $this |
||
143 | */ |
||
144 | 2 | public function resetFilters() |
|
150 | } |
||
151 |