1 | <?php |
||
31 | class Reader |
||
32 | { |
||
33 | /** |
||
34 | * @var \FeedIo\Adapter\ClientInterface; |
||
35 | */ |
||
36 | protected $client; |
||
37 | |||
38 | /** |
||
39 | * @var \Psr\Log\LoggerInterface |
||
40 | */ |
||
41 | protected $logger; |
||
42 | |||
43 | /** |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $parsers = array(); |
||
47 | |||
48 | /** |
||
49 | * @param ClientInterface $client |
||
50 | * @param LoggerInterface $logger |
||
51 | */ |
||
52 | 12 | public function __construct(ClientInterface $client, LoggerInterface $logger) |
|
57 | |||
58 | /** |
||
59 | * @param Parser $parser |
||
60 | * @return $this |
||
61 | */ |
||
62 | 12 | public function addParser(ParserAbstract $parser) |
|
69 | |||
70 | /** |
||
71 | * adds a filter to every parsers |
||
72 | * |
||
73 | * @param \FeedIo\FilterInterface $filter |
||
74 | * @return $this |
||
75 | */ |
||
76 | 2 | public function addFilter(FilterInterface $filter) |
|
84 | |||
85 | /** |
||
86 | * Reset filters on every parsers |
||
87 | * @return $this |
||
88 | */ |
||
89 | 1 | public function resetFilters() |
|
90 | { |
||
91 | 1 | foreach ($this->parsers as $parser) { |
|
92 | 1 | $parser->resetFilters(); |
|
93 | 1 | } |
|
94 | |||
95 | 1 | return $this; |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * @param $url |
||
100 | * @param FeedInterface $feed |
||
101 | * @param \DateTime $modifiedSince |
||
102 | * @return \FeedIo\Reader\Result |
||
103 | * @throws ReadErrorException |
||
104 | */ |
||
105 | 4 | public function read($url, FeedInterface $feed, \DateTime $modifiedSince = null) |
|
128 | |||
129 | /** |
||
130 | * @param Document $document |
||
131 | * @param FeedInterface $feed |
||
132 | * @return FeedInterface |
||
133 | * @throws Parser\UnsupportedFormatException |
||
134 | * @throws Reader\NoAccurateParserException |
||
135 | */ |
||
136 | 2 | public function parseDocument(Document $document, FeedInterface $feed) |
|
143 | |||
144 | /** |
||
145 | * @param Document $document |
||
146 | * @return ParserAbstract |
||
147 | * @throws Reader\NoAccurateParserException |
||
148 | */ |
||
149 | 4 | public function getAccurateParser(Document $document) |
|
161 | } |
||
162 |