1 | <?php declare(strict_types=1); |
||
72 | class FeedIo |
||
73 | { |
||
74 | |||
75 | /** |
||
76 | * @var \FeedIo\Reader |
||
77 | */ |
||
78 | protected $reader; |
||
79 | |||
80 | /** |
||
81 | * @var \FeedIo\Rule\DateTimeBuilder |
||
82 | */ |
||
83 | protected $dateTimeBuilder; |
||
84 | |||
85 | /** |
||
86 | * @var \Psr\Log\LoggerInterface |
||
87 | */ |
||
88 | protected $logger; |
||
89 | |||
90 | /** |
||
91 | * @var array |
||
92 | */ |
||
93 | protected $standards; |
||
94 | |||
95 | /** |
||
96 | * @var \FeedIo\Reader\FixerSet |
||
97 | */ |
||
98 | protected $fixerSet; |
||
99 | |||
100 | /** |
||
101 | * @param \FeedIo\Adapter\ClientInterface $client |
||
102 | * @param \Psr\Log\LoggerInterface $logger |
||
103 | */ |
||
104 | 11 | public function __construct(ClientInterface $client, LoggerInterface $logger) |
|
105 | { |
||
106 | 11 | $this->logger = $logger; |
|
107 | 11 | $this->dateTimeBuilder = new DateTimeBuilder($logger); |
|
108 | 11 | $this->setReader(new Reader($client, $logger)); |
|
109 | 11 | $this->loadCommonStandards(); |
|
110 | 11 | $this->loadFixerSet(); |
|
111 | 11 | } |
|
112 | |||
113 | /** |
||
114 | * Loads main standards (RSS, RDF, Atom) in current object's attributes |
||
115 | * |
||
116 | * @return FeedIo |
||
117 | */ |
||
118 | 11 | protected function loadCommonStandards() : FeedIo |
|
127 | |||
128 | /** |
||
129 | * adds a filter to the reader |
||
130 | * |
||
131 | * @param \FeedIo\FilterInterface $filter |
||
132 | * @return FeedIo |
||
133 | */ |
||
134 | 2 | public function addFilter(FilterInterface $filter) : FeedIo |
|
140 | |||
141 | /** |
||
142 | * Returns main standards |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | 11 | public function getCommonStandards() : array |
|
152 | |||
153 | /** |
||
154 | * @param string $name |
||
155 | * @param \FeedIo\StandardAbstract $standard |
||
156 | * @return FeedIo |
||
157 | */ |
||
158 | 11 | public function addStandard(string $name, StandardAbstract $standard) : FeedIo |
|
167 | |||
168 | /** |
||
169 | * @param string $format |
||
170 | * @param StandardAbstract $standard |
||
171 | * @return ParserAbstract |
||
172 | */ |
||
173 | 10 | public function newParser(string $format, StandardAbstract $standard) : ParserAbstract |
|
183 | |||
184 | /** |
||
185 | * @return \FeedIo\Reader\FixerSet |
||
186 | */ |
||
187 | 1 | public function getFixerSet() : FixerSet |
|
191 | |||
192 | /** |
||
193 | * @return FeedIo |
||
194 | */ |
||
195 | 10 | protected function loadFixerSet() : FeedIo |
|
206 | |||
207 | /** |
||
208 | * @param FixerAbstract $fixer |
||
209 | * @return FeedIo |
||
210 | */ |
||
211 | 10 | public function addFixer(FixerAbstract $fixer) : FeedIo |
|
218 | |||
219 | /** |
||
220 | * @return array |
||
221 | */ |
||
222 | 10 | public function getBaseFixers() : array |
|
229 | |||
230 | /** |
||
231 | * @param array $formats |
||
232 | * @return FeedIo |
||
233 | */ |
||
234 | 1 | public function addDateFormats(array $formats) : FeedIo |
|
242 | |||
243 | /** |
||
244 | * @return \FeedIo\Rule\DateTimeBuilder |
||
245 | */ |
||
246 | 11 | public function getDateTimeBuilder() : DateTimeBuilder |
|
250 | |||
251 | /** |
||
252 | * @return \FeedIo\Reader |
||
253 | */ |
||
254 | 4 | public function getReader() : Reader |
|
258 | |||
259 | /** |
||
260 | * @param \FeedIo\Reader |
||
261 | * @return FeedIo |
||
262 | */ |
||
263 | 11 | public function setReader(Reader $reader) : FeedIo |
|
269 | |||
270 | /** |
||
271 | * @param iterable $requests |
||
272 | * @param CallbackInterface $callback |
||
273 | * @param string $feedClass |
||
274 | */ |
||
275 | public function readAsync(iterable $requests, CallbackInterface $callback, string $feedClass = '\FeedIo\Feed') : void |
||
281 | |||
282 | /** |
||
283 | * @param string $url |
||
284 | * @param FeedInterface $feed |
||
285 | * @param \DateTime $modifiedSince |
||
286 | * @return \FeedIo\Reader\Result |
||
287 | */ |
||
288 | 2 | public function read(string $url, FeedInterface $feed = null, \DateTime $modifiedSince = null) : Result |
|
305 | |||
306 | /** |
||
307 | * @param string $url |
||
308 | * @param \DateTime $modifiedSince |
||
309 | * @return \FeedIo\Reader\Result |
||
310 | */ |
||
311 | 1 | public function readSince(string $url, \DateTime $modifiedSince) : Result |
|
315 | |||
316 | /** |
||
317 | * @return FeedIo |
||
318 | */ |
||
319 | 1 | public function resetFilters() : FeedIo |
|
325 | |||
326 | /** |
||
327 | * @param FeedInterface $feed |
||
328 | * @param string $standard Standard's name |
||
329 | * @return string |
||
330 | */ |
||
331 | 1 | public function format(FeedInterface $feed, string $standard) : string |
|
339 | |||
340 | /** |
||
341 | * @param \FeedIo\FeedInterface $feed |
||
342 | * @return string |
||
343 | */ |
||
344 | 1 | public function toRss(FeedInterface $feed) : string |
|
348 | |||
349 | /** |
||
350 | * @param \FeedIo\FeedInterface $feed |
||
351 | * @return string |
||
352 | */ |
||
353 | 1 | public function toAtom(FeedInterface $feed) : string |
|
357 | |||
358 | /** |
||
359 | * @param \FeedIo\FeedInterface $feed |
||
360 | * @return string |
||
361 | */ |
||
362 | 1 | public function toJson(FeedInterface $feed) : string |
|
366 | |||
367 | |||
368 | /** |
||
369 | * @param string $name |
||
370 | * @return \FeedIo\StandardAbstract |
||
371 | * @throws \OutOfBoundsException |
||
372 | */ |
||
373 | 2 | public function getStandard(string $name) : StandardAbstract |
|
382 | |||
383 | /** |
||
384 | * @param \FeedIo\FeedInterface $feed |
||
385 | * @param string $message |
||
386 | * @return FeedIo |
||
387 | */ |
||
388 | 2 | protected function logAction(FeedInterface $feed, string $message) : FeedIo |
|
395 | } |
||
396 |