diff --git a/fluxRSS/metier/Flux.php b/fluxRSS/metier/Flux.php index d68b0ba..a167fbe 100755 --- a/fluxRSS/metier/Flux.php +++ b/fluxRSS/metier/Flux.php @@ -4,6 +4,7 @@ namespace metier; class Flux { + private string $id; private string $flux; /** @@ -21,4 +22,12 @@ class Flux { $this->flux = $flux; } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } } \ No newline at end of file diff --git a/fluxRSS/model/Parser.php b/fluxRSS/model/Parser.php new file mode 100644 index 0000000..26b69a2 --- /dev/null +++ b/fluxRSS/model/Parser.php @@ -0,0 +1,42 @@ +load($flux->getFlux()); + $items = $dom->getElementsByTagName('item'); + + foreach ($items as $item) { + $title = $item->getElementsByTagName('title')[0]->nodeValue; + + $date = $item->getElementsByTagName('pubDate')[0]->nodeValue; + + $guid = $item->getElementsByTagName('guid')[0]->nodeValue; + + $link = $item->getElementsByTagName('link')[0]->nodeValue; + + $description = $item->getElementsByTagName('description')[0]->nodeValue; + + //manque ajout de l'image + + $tabArticle[] = new Article((int)Null, $title, $date, $description, $guid, $link, $description, $flux->getId()); + } + return $tabArticle; + } + + public function parseAll(Flux $fluxes){ + foreach ($fluxes as $flux){ + $tabArticles[] =$this->parseArticles($flux); + } + return $tabArticles; + } +} \ No newline at end of file