Clean code

This commit is contained in:
Laurent Destailleur 2024-04-24 20:29:37 +02:00
parent ac1e6fccb8
commit 5166eee88c
2 changed files with 28 additions and 13 deletions

View file

@ -85,6 +85,8 @@ $config['suppress_issue_types'] = [
'PhanPluginDuplicateConditionalNullCoalescing', // Not essential - 990+ occurrences
'PhanPluginRedundantAssignmentInGlobalScope', // Not essential, a lot of false warning
'PhanPluginDuplicateCatchStatementBody', // Requires PHP7.1 - 50+ occurrences
];
'PhanPluginUnknownObjectMethodCall', // False positive for some class
];
return $config;

View file

@ -54,11 +54,15 @@ class DolGeoPHP
public function parseGeoString($value)
{
$geom = geoPHP::load($value, 'wkt');
$geojson = $geom->out('json');
$centroid = $geom->getCentroid();
$centroidjson = $centroid->out('json');
if ($geom) {
$geojson = $geom->out('json');
$centroid = $geom->getCentroid();
$centroidjson = $centroid->out('json');
return array('geojson' => $geojson, 'centroid' => $centroid, 'centroidjson' => $centroidjson);
return array('geojson' => $geojson, 'centroid' => $centroid, 'centroidjson' => $centroidjson);
} else {
return array();
}
}
/**
@ -69,9 +73,12 @@ class DolGeoPHP
*/
public function getXYString($value)
{
$geom = geoPHP::load($value, 'wkt');
$value = $geom->x().' '.$geom->y();
$value = '';
$geom = geoPHP::load($value, 'wkt');
if ($geom) {
$value = $geom->x().' '.$geom->y();
}
return $value;
}
@ -79,13 +86,16 @@ class DolGeoPHP
* Return a string with x and y
*
* @param mixed $value Value
* @return string X space Y
* @return string Class : num points
*/
public function getPointString($value)
{
$geom = geoPHP::load($value, 'wkt');
$value = get_class($geom) . ' : '. $geom->numPoints() . ' Points';
$value = '';
$geom = geoPHP::load($value, 'wkt');
if ($geom) {
$value = get_class($geom) . ' : '. $geom->numPoints() . ' Points';
}
return $value;
}
@ -93,13 +103,16 @@ class DolGeoPHP
* Return wkt
*
* @param string $geojson A json string
* @return string X space Y
* @return mixed Value key
*/
public function getWkt($geojson)
{
$geom = geoPHP::load($geojson, 'json');
$value_key = $geom->out('wkt');
$value_key = '';
$geom = geoPHP::load($geojson, 'json');
if ($geom) {
$value_key = $geom->out('wkt');
}
return $value_key;
}
}