ThresholdRange::fromString(): default to -∞:∞

refs #8194
This commit is contained in:
Alexander A. Klimov 2016-04-29 10:33:26 +02:00 committed by Johannes Meyer
parent 54002cb3e5
commit 881267d829
2 changed files with 7 additions and 3 deletions

View File

@ -323,14 +323,14 @@ class Perfdata
case 3: case 3:
$this->rawCriticalThreshold = trim($parts[2]); $this->rawCriticalThreshold = trim($parts[2]);
$this->criticalThreshold = self::convert( $this->criticalThreshold = self::convert(
ThresholdRange::fromString($this->rawCriticalThreshold ?: '~:'), ThresholdRange::fromString($this->rawCriticalThreshold),
$this->unit $this->unit
); );
// Fallthrough // Fallthrough
case 2: case 2:
$this->rawWarningThreshold = trim($parts[1]); $this->rawWarningThreshold = trim($parts[1]);
$this->warningThreshold = self::convert( $this->warningThreshold = self::convert(
ThresholdRange::fromString($this->rawWarningThreshold ?: '~:'), ThresholdRange::fromString($this->rawWarningThreshold),
$this->unit $this->unit
); );
} }

View File

@ -36,10 +36,14 @@ class ThresholdRange
* *
* @return ThresholdRange * @return ThresholdRange
*/ */
public static function fromString($rawRange) public static function fromString($rawRange = '')
{ {
$range = new static(); $range = new static();
if ($rawRange === '') {
return $range;
}
$rawRange = ltrim($rawRange); $rawRange = ltrim($rawRange);
if (substr($rawRange, 0, 1) === '@') { if (substr($rawRange, 0, 1) === '@') {
$range->setInverted(); $range->setInverted();