1 | <?php |
||
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 | 8 | public function __construct(ClientInterface $client, LoggerInterface $logger) |
|
105 | { |
||
106 | 8 | $this->logger = $logger; |
|
107 | 8 | $this->dateTimeBuilder = new DateTimeBuilder($logger); |
|
108 | 8 | $this->setReader(new Reader($client, $logger)); |
|
109 | 8 | $this->loadCommonStandards(); |
|
110 | 8 | $this->loadFixerSet(); |
|
111 | 8 | } |
|
112 | |||
113 | /** |
||
114 | * Loads main standards (RSS, RDF, Atom) in current object's attributes |
||
115 | * |
||
116 | * @return $this |
||
117 | */ |
||
118 | 8 | protected function loadCommonStandards() |
|
127 | |||
128 | /** |
||
129 | * adds a filter to the reader |
||
130 | * |
||
131 | * @param \FeedIo\FilterInterface $filter |
||
132 | * @return $this |
||
133 | */ |
||
134 | 1 | public function addFilter(FilterInterface $filter) |
|
140 | |||
141 | /** |
||
142 | * Returns main standards |
||
143 | * |
||
144 | * @return array |
||
145 | */ |
||
146 | 8 | public function getCommonStandards() |
|
154 | |||
155 | /** |
||
156 | * @param string $name |
||
157 | * @param \FeedIo\StandardAbstract $standard |
||
158 | * @return $this |
||
159 | */ |
||
160 | 8 | public function addStandard($name, StandardAbstract $standard) |
|
169 | |||
170 | /** |
||
171 | * @param string $format |
||
172 | * @param StandardAbstract $standard |
||
173 | * @return object |
||
174 | */ |
||
175 | 7 | public function newParser($format, StandardAbstract $standard) |
|
185 | |||
186 | /** |
||
187 | * @return \FeedIo\Reader\FixerSet |
||
188 | */ |
||
189 | 1 | public function getFixerSet() |
|
193 | |||
194 | /** |
||
195 | * @return $this |
||
196 | */ |
||
197 | 7 | protected function loadFixerSet() |
|
208 | |||
209 | /** |
||
210 | * @param FixerAbstract $fixer |
||
211 | * @return $this |
||
212 | */ |
||
213 | 7 | public function addFixer(FixerAbstract $fixer) |
|
220 | |||
221 | /** |
||
222 | * @return array |
||
223 | */ |
||
224 | 7 | public function getBaseFixers() |
|
232 | |||
233 | /** |
||
234 | * @param array $formats |
||
235 | * @return $this |
||
236 | */ |
||
237 | 1 | public function addDateFormats(array $formats) |
|
245 | |||
246 | /** |
||
247 | * @return \FeedIo\Rule\DateTimeBuilder |
||
248 | */ |
||
249 | 2 | public function getDateTimeBuilder() |
|
253 | |||
254 | /** |
||
255 | * @return \FeedIo\Reader |
||
256 | */ |
||
257 | 2 | public function getReader() |
|
261 | |||
262 | /** |
||
263 | * @param \FeedIo\Reader |
||
264 | * @return $this |
||
265 | */ |
||
266 | 8 | public function setReader(Reader $reader) |
|
272 | |||
273 | /** |
||
274 | * @param $url |
||
275 | * @param FeedInterface $feed |
||
276 | * @param \DateTime $modifiedSince |
||
277 | * @return \FeedIo\Reader\Result |
||
278 | */ |
||
279 | 1 | public function read($url, FeedInterface $feed = null, \DateTime $modifiedSince = null) |
|
296 | |||
297 | /** |
||
298 | * @param $url |
||
299 | * @param \DateTime $modifiedSince |
||
300 | * @return \FeedIo\Reader\Result |
||
301 | */ |
||
302 | 1 | public function readSince($url, \DateTime $modifiedSince) |
|
306 | |||
307 | /** |
||
308 | * @return $this |
||
309 | */ |
||
310 | public function resetFilters() |
||
316 | |||
317 | /** |
||
318 | * @param FeedInterface $feed |
||
319 | * @param string $standard Standard's name |
||
320 | * @return \DomDocument |
||
321 | */ |
||
322 | 1 | public function format(FeedInterface $feed, $standard) |
|
330 | |||
331 | /** |
||
332 | * @param \FeedIo\FeedInterface $feed |
||
333 | * @return \DomDocument |
||
334 | */ |
||
335 | 1 | public function toRss(FeedInterface $feed) |
|
339 | |||
340 | /** |
||
341 | * @param \FeedIo\FeedInterface $feed |
||
342 | * @return \DomDocument |
||
343 | */ |
||
344 | 1 | public function toAtom(FeedInterface $feed) |
|
348 | |||
349 | /** |
||
350 | * @param string $name |
||
351 | * @return \FeedIo\StandardAbstract |
||
352 | * @throws \OutOfBoundsException |
||
353 | */ |
||
354 | 2 | public function getStandard($name) |
|
363 | |||
364 | /** |
||
365 | * @param \FeedIo\FeedInterface $feed |
||
366 | * @param string $message |
||
367 | * @return $this |
||
368 | */ |
||
369 | 1 | protected function logAction(FeedInterface $feed, $message) |
|
376 | } |
||
377 |