Added empty string check (#15235)

* Added empty string check

* replaced tabs with spaces

replaced tabs with spaces

* Removed '(', ')' and enlarged if clause

* Added one space and removed an empty row

* removed is_null

Removed is_null check as static code analysis says that this variable cannot be null at this time

* compact form

* handle spaces

In case the sysName is " " (one space). Good to trim anyway.

---------

Co-authored-by: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com>
This commit is contained in:
Fehler12
2023-08-21 00:17:25 +02:00
committed by GitHub
parent 69297c9e91
commit cbe2ba55ce

View File

@@ -180,12 +180,15 @@ class Device extends BaseModel
{
$hostname_is_ip = IP::isValid($this->hostname);
return SimpleTemplate::parse($this->display ?: \LibreNMS\Config::get('device_display_default', '{{ $hostname }}'), [
$return_value = SimpleTemplate::parse($this->display ?: \LibreNMS\Config::get('device_display_default', '{{ $hostname }}'), [
'hostname' => $this->hostname,
'sysName' => $this->sysName ?: $this->hostname,
'sysName_fallback' => $hostname_is_ip ? $this->sysName : $this->hostname,
'ip' => $this->overwrite_ip ?: ($hostname_is_ip ? $this->hostname : $this->ip),
]);
// in case the displayName is a string without any content, return hostname
return trim($return_value) ?: $this->hostname;
}
/**