New utility Number::constrainInteger() (#15663)

* New utility Number::constrainInteger()
Fixes a bug with Number::unsignedAsSigned() and implements signed support as well.

* cleanup

* Apply fixes from StyleCI

* Remove default cases

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Tony Murray
2023-12-20 09:21:40 -06:00
committed by GitHub
parent b4a61636c1
commit 6bea8cffa6
4 changed files with 105 additions and 18 deletions

View File

@@ -32,6 +32,7 @@ use App\Models\PortVdsl;
use App\Observers\ModuleModelObserver;
use Illuminate\Support\Collection;
use LibreNMS\DB\SyncsModels;
use LibreNMS\Enum\IntegerType;
use LibreNMS\Interfaces\Data\DataStorageInterface;
use LibreNMS\Interfaces\Module;
use LibreNMS\OS;
@@ -139,7 +140,7 @@ class Xdsl implements Module
if (isset($data[$oid])) {
if ($oid == 'adslAtucCurrOutputPwr') {
// workaround Cisco Bug CSCvj53634
$data[$oid] = Number::unsignedAsSigned($data[$oid]);
$data[$oid] = Number::constrainInteger($data[$oid], IntegerType::int32);
}
$data[$oid] = $data[$oid] / 10;
}