From f8f9005db64d141457f573763970e6288cebc9aa Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 1 Jul 2026 14:25:19 +0000 Subject: [PATCH] Apply fixes from StyleCI --- LibreNMS/Data/Graphing/AbstractGraph.php | 2 ++ .../Data/Graphing/Builders/MultiLineGraphBuilder.php | 9 +++++++++ .../Builders/MultiSimplexSeparatedGraphBuilder.php | 12 ++++++++++++ LibreNMS/Data/Graphing/Device/ProcessorGraph.php | 2 ++ LibreNMS/Data/Graphing/GraphFactory.php | 3 ++- LibreNMS/Data/Graphing/LegacyGraph.php | 9 ++++++++- LibreNMS/Exceptions/InvalidGraph.php | 9 +++++---- LibreNMS/Interfaces/Data/Graphing/GraphInterface.php | 6 ++++++ app/Console/Commands/GraphDetail.php | 9 ++++----- 9 files changed, 50 insertions(+), 11 deletions(-) diff --git a/LibreNMS/Data/Graphing/AbstractGraph.php b/LibreNMS/Data/Graphing/AbstractGraph.php index e4a9fe9f24..1b0392d9e4 100644 --- a/LibreNMS/Data/Graphing/AbstractGraph.php +++ b/LibreNMS/Data/Graphing/AbstractGraph.php @@ -1,4 +1,5 @@ unitText = $unitText; + return $this; } public function units(string $units): self { $this->units = $units; + return $this; } public function colours(string $colours): self { $this->colours = $colours; + return $this; } public function scaleMin(float $scaleMin): self { $this->scaleMin = $scaleMin; + return $this; } public function scaleMax(float $scaleMax): self { $this->scaleMax = $scaleMax; + return $this; } public function noTotal(bool $noTotal = true): self { $this->nototal = $noTotal; + return $this; } public function descrLen(int $descrLen): self { $this->descrLen = $descrLen; + return $this; } @@ -101,6 +109,7 @@ public function addDataset( 'areacolour' => $areaColour, 'invert' => $invert, ]; + return $this; } diff --git a/LibreNMS/Data/Graphing/Builders/MultiSimplexSeparatedGraphBuilder.php b/LibreNMS/Data/Graphing/Builders/MultiSimplexSeparatedGraphBuilder.php index 66740948a5..22f3ce50b5 100644 --- a/LibreNMS/Data/Graphing/Builders/MultiSimplexSeparatedGraphBuilder.php +++ b/LibreNMS/Data/Graphing/Builders/MultiSimplexSeparatedGraphBuilder.php @@ -1,4 +1,5 @@ unitText = $unitText; + return $this; } public function totalUnits(string $totalUnits): self { $this->totalUnits = $totalUnits; + return $this; } public function colours(string $colours): self { $this->colours = $colours; + return $this; } public function scaleMin(float $scaleMin): self { $this->scaleMin = $scaleMin; + return $this; } public function scaleMax(float $scaleMax): self { $this->scaleMax = $scaleMax; + return $this; } public function divider(float $divider): self { $this->divider = $divider; + return $this; } public function multiplier(float $multiplier): self { $this->multiplier = $multiplier; + return $this; } public function textOrig(bool $textOrig = true): self { $this->textOrig = $textOrig; + return $this; } public function noTotal(bool $noTotal = true): self { $this->nototal = $noTotal; + return $this; } public function descrLen(int $descrLen): self { $this->descrLen = $descrLen; + return $this; } @@ -116,6 +127,7 @@ public function addDataset( 'descr' => $description, 'colour' => $colour, ]; + return $this; } diff --git a/LibreNMS/Data/Graphing/Device/ProcessorGraph.php b/LibreNMS/Data/Graphing/Device/ProcessorGraph.php index 63f0d03fef..f131cbe93f 100644 --- a/LibreNMS/Data/Graphing/Device/ProcessorGraph.php +++ b/LibreNMS/Data/Graphing/Device/ProcessorGraph.php @@ -1,4 +1,5 @@ processors as $proc) { $files[] = Rrd::name($this->device->hostname, ['processor', $proc->processor_type, $proc->processor_index]); } + return $files; } diff --git a/LibreNMS/Data/Graphing/GraphFactory.php b/LibreNMS/Data/Graphing/GraphFactory.php index bab8ad240b..0e9a7f99a2 100644 --- a/LibreNMS/Data/Graphing/GraphFactory.php +++ b/LibreNMS/Data/Graphing/GraphFactory.php @@ -1,4 +1,5 @@ $vars]); } diff --git a/LibreNMS/Data/Graphing/LegacyGraph.php b/LibreNMS/Data/Graphing/LegacyGraph.php index b48ec0d1d1..01ccb10d13 100644 --- a/LibreNMS/Data/Graphing/LegacyGraph.php +++ b/LibreNMS/Data/Graphing/LegacyGraph.php @@ -1,4 +1,5 @@ $vars + * * @throws InvalidGraph */ public function __construct( @@ -103,6 +106,7 @@ private function load(): void if (! $auth) { $this->loaded = true; + return; } @@ -144,19 +148,21 @@ private function load(): void public function authorize(): bool { $this->load(); + return $this->authorized; } - public function definition(GraphParameters $graph_params): array { $this->load(); + return $this->rrdOptions; } public function getPageTitle(): string { $this->load(); + return $this->pageTitle ?? $this->getGraphTitle(); } @@ -178,6 +184,7 @@ public function getGraphTitle(): string public function getRrdFiles(): array { $this->load(); + return $this->rrdFiles; } } diff --git a/LibreNMS/Exceptions/InvalidGraph.php b/LibreNMS/Exceptions/InvalidGraph.php index 6bb3ff163f..99bde5b542 100644 --- a/LibreNMS/Exceptions/InvalidGraph.php +++ b/LibreNMS/Exceptions/InvalidGraph.php @@ -1,4 +1,5 @@ line("Type: $graph->type"); $this->line("Subtype: $graph->subtype"); $this->line('Authorized: ' . ($graph->authorize() ? 'true' : 'false')); - $this->line("Graph Title: " . $graph->getGraphTitle()); - $this->line("Page Title: " . substr($graph->getPageTitle(), 0, 80)); - $this->line("Rrd Files: " . implode(', ', array_map(fn($f) => basename($f), $graph->getRrdFiles()))); - $this->line("Definition: " . substr(implode(' ', $graph->definition()), 80)); - + $this->line('Graph Title: ' . $graph->getGraphTitle()); + $this->line('Page Title: ' . substr($graph->getPageTitle(), 0, 80)); + $this->line('Rrd Files: ' . implode(', ', array_map(fn ($f) => basename($f), $graph->getRrdFiles()))); + $this->line('Definition: ' . substr(implode(' ', $graph->definition()), 80)); return 0; }