mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-04 17:04:53 +02:00
up labourage long noms
This commit is contained in:
parent
5b18e4fb08
commit
5c6a28df53
1 changed files with 40 additions and 20 deletions
|
@ -243,7 +243,7 @@ class Place
|
|||
$this->setOsmVersion($overpass_data['version']);
|
||||
}
|
||||
if (isset($overpass_data['user'])) {
|
||||
$this->setOsmUser($overpass_data['user']);
|
||||
$this->setOsmUser($this->truncateString($overpass_data['user'], 255));
|
||||
}
|
||||
if (isset($overpass_data['uid'])) {
|
||||
$this->setOsmUid($overpass_data['uid']);
|
||||
|
@ -259,23 +259,23 @@ class Place
|
|||
}
|
||||
|
||||
// Setters from tags
|
||||
$this->setName($tags['name'] ?? null);
|
||||
$this->setName($this->truncateString($tags['name'] ?? null, 255));
|
||||
|
||||
$street = isset($tags['addr:street']) ? $tags['addr:street'] : (isset($tags['contact:street']) ? $tags['contact:street'] : null);
|
||||
$this->setStreet($street);
|
||||
$this->setStreet($this->truncateString($street, 255));
|
||||
|
||||
$housenumber = isset($tags['addr:housenumber']) ? $tags['addr:housenumber'] : (isset($tags['contact:housenumber']) ? $tags['contact:housenumber'] : null);
|
||||
$this->setHousenumber($housenumber);
|
||||
$this->setHousenumber($this->truncateString($housenumber, 255));
|
||||
|
||||
if (isset($tags['addr:postcode'])) {
|
||||
$this->setZipCode(intval($tags['addr:postcode']));
|
||||
}
|
||||
|
||||
$email = isset($tags['contact:email']) ? $tags['contact:email'] : (isset($tags['email']) ? $tags['email'] : null);
|
||||
$this->setEmail($email);
|
||||
$this->setEmail($this->truncateString($email, 255));
|
||||
|
||||
$siret = isset($tags['ref:FR:SIRET']) ? $tags['ref:FR:SIRET'] : null;
|
||||
$this->setSiret($siret);
|
||||
$this->setSiret($this->truncateString($siret, 255));
|
||||
|
||||
// Boolean "has" properties
|
||||
$this->setHasOpeningHours(!empty($tags['opening_hours']));
|
||||
|
@ -312,7 +312,7 @@ class Place
|
|||
$noteContent .= "FIXME: " . $tags['fixme'];
|
||||
$hasNote = true;
|
||||
}
|
||||
$this->setNoteContent($noteContent ? $noteContent : null);
|
||||
$this->setNoteContent($this->truncateString($noteContent ? $noteContent : null, 255));
|
||||
$this->setHasNote($hasNote);
|
||||
$this->setNote($noteContent);
|
||||
}
|
||||
|
@ -753,6 +753,26 @@ class Place
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to truncate strings to a maximum length
|
||||
*
|
||||
* @param string|null $string The string to truncate
|
||||
* @param int $maxLength The maximum length
|
||||
* @return string|null The truncated string or null if input was null
|
||||
*/
|
||||
private function truncateString(?string $string, int $maxLength): ?string
|
||||
{
|
||||
if ($string === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mb_strlen($string) <= $maxLength) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
return mb_substr($string, 0, $maxLength);
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue