[PanneauPocketBridge] enhancements (#2940)

* [PanneauPocketBridge] small fixes

* [PanneauPocketBridge] rename variable

* [PanneauPocketBridge] remove function call

Co-authored-by: Florent VIOLLEAU <florent.violleau@samsic.fr>
This commit is contained in:
floviolleau 2022-10-12 21:10:58 +02:00 committed by GitHub
parent 7895fa895f
commit 3ea7d46837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -113,8 +113,8 @@ class PanneauPocketBridge extends BridgeAbstract
public function collectData() public function collectData()
{ {
$found = array_search($this->getInput('cities'), self::CITIES); $matchedCity = array_search($this->getInput('cities'), self::CITIES);
$city = strtolower($this->getInput('cities') . '-' . $found); $city = strtolower($this->getInput('cities') . '-' . $matchedCity);
$url = sprintf('https://app.panneaupocket.com/ville/%s', urlencode($city)); $url = sprintf('https://app.panneaupocket.com/ville/%s', urlencode($city));
$html = getSimpleHTMLDOM($url); $html = getSimpleHTMLDOM($url);
@ -139,14 +139,14 @@ class PanneauPocketBridge extends BridgeAbstract
/** /**
* Produce self::CITIES array * Produce self::CITIES array
*/ */
private static function getCities() private static function getCities($zipcodeStartWith)
{ {
$cities = json_decode(getContents(self::URI . '/public-api/city'), true); $cities = json_decode(getContents(self::URI . '/public-api/city'), true);
$formattedCities = null; $formattedCities = null;
$citiesString = '[<br>'; $citiesString = '[<br>';
foreach ($cities as $city) { foreach ($cities as $city) {
if (str_starts_with($city['postCode'], '35')) { if (str_starts_with($city['postCode'], $zipcodeStartWith)) {
$formattedCities[$city['name'] . ' - ' . $city['postCode']] = $city['id']; $formattedCities[$city['name'] . ' - ' . $city['postCode']] = $city['id'];
$citiesString .= ' "' . $city['name'] . '-' . $city['postCode'] . '" => "' . $city['id'] . '",'; $citiesString .= ' "' . $city['name'] . '-' . $city['postCode'] . '" => "' . $city['id'] . '",';
$citiesString .= '<br>'; $citiesString .= '<br>';