refactor(donnons) (#4389)

This commit is contained in:
Dag 2025-01-03 06:49:10 +01:00 committed by GitHub
parent 3fc38c15a3
commit 662e0bfa95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* Retourne les dons d'une recherche filtrée sur le site Donnons.org
* Example: https://donnons.org/Sport/Ile-de-France
@ -44,11 +46,14 @@ class DonnonsBridge extends BridgeAbstract
{
$uri = $this->getPageURI($page);
$html = getSimpleHTMLDOM($uri);
$dom = getSimpleHTMLDOM($uri);
$searchDiv = $html->find('div[id=search]', 0);
$searchDiv = $dom->find('div[id=search]', 0);
if (! $searchDiv) {
return;
}
if (!is_null($searchDiv)) {
$elements = $searchDiv->find('a.lst-annonce');
foreach ($elements as $element) {
$item = [];
@ -97,7 +102,6 @@ class DonnonsBridge extends BridgeAbstract
$this->items[] = $item;
}
}
}
private function getPageURI($page)
{