public function SensorResult::toNumber in Monitoring 8
Same name and namespace in other branches
- 7 lib/Drupal/monitoring/Result/SensorResult.php \Drupal\monitoring\Result\SensorResult::toNumber()
Casts/processes the sensor value into numeric representation.
Return value
number Numeric sensor value.
Overrides SensorResultInterface::toNumber
1 call to SensorResult::toNumber()
- SensorResult::toArray in src/
Result/ SensorResult.php - Returns sensor result data as array.
File
- src/
Result/ SensorResult.php, line 416
Class
- SensorResult
- Generic container for the sensor result.
Namespace
Drupal\monitoring\ResultCode
public function toNumber() {
$sensor_value = $this
->getValue();
if (is_numeric($sensor_value)) {
return $sensor_value;
}
// Casting to int should be good enough as boolean will get casted to 0/1
// and string as well.
return (int) $sensor_value;
}