Skip to content

Commit 2fd3f91

Browse files
committed
Style fixes
1 parent 93cfa91 commit 2fd3f91

9 files changed

Lines changed: 49 additions & 11 deletions

File tree

LibreNMS/Data/Graphing/AbstractGraph.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* AbstractGraph.php
45
*
@@ -53,6 +54,7 @@ public function fill(array $vars): self
5354
}
5455
}
5556
}
57+
5658
return $this;
5759
}
5860
}

LibreNMS/Data/Graphing/Builders/MultiLineGraphBuilder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* MultiLineGraphBuilder.php
45
*
@@ -44,42 +45,49 @@ class MultiLineGraphBuilder
4445
public function unitText(string $unitText): self
4546
{
4647
$this->unitText = $unitText;
48+
4749
return $this;
4850
}
4951

5052
public function units(string $units): self
5153
{
5254
$this->units = $units;
55+
5356
return $this;
5457
}
5558

5659
public function colours(string $colours): self
5760
{
5861
$this->colours = $colours;
62+
5963
return $this;
6064
}
6165

6266
public function scaleMin(float $scaleMin): self
6367
{
6468
$this->scaleMin = $scaleMin;
69+
6570
return $this;
6671
}
6772

6873
public function scaleMax(float $scaleMax): self
6974
{
7075
$this->scaleMax = $scaleMax;
76+
7177
return $this;
7278
}
7379

7480
public function noTotal(bool $noTotal = true): self
7581
{
7682
$this->nototal = $noTotal;
83+
7784
return $this;
7885
}
7986

8087
public function descrLen(int $descrLen): self
8188
{
8289
$this->descrLen = $descrLen;
90+
8391
return $this;
8492
}
8593

@@ -101,6 +109,7 @@ public function addDataset(
101109
'areacolour' => $areaColour,
102110
'invert' => $invert,
103111
];
112+
104113
return $this;
105114
}
106115

LibreNMS/Data/Graphing/Builders/MultiSimplexSeparatedGraphBuilder.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* MultiSimplexSeparatedGraphBuilder.php
45
*
@@ -47,60 +48,70 @@ class MultiSimplexSeparatedGraphBuilder
4748
public function unitText(string $unitText): self
4849
{
4950
$this->unitText = $unitText;
51+
5052
return $this;
5153
}
5254

5355
public function totalUnits(string $totalUnits): self
5456
{
5557
$this->totalUnits = $totalUnits;
58+
5659
return $this;
5760
}
5861

5962
public function colours(string $colours): self
6063
{
6164
$this->colours = $colours;
65+
6266
return $this;
6367
}
6468

6569
public function scaleMin(float $scaleMin): self
6670
{
6771
$this->scaleMin = $scaleMin;
72+
6873
return $this;
6974
}
7075

7176
public function scaleMax(float $scaleMax): self
7277
{
7378
$this->scaleMax = $scaleMax;
79+
7480
return $this;
7581
}
7682

7783
public function divider(float $divider): self
7884
{
7985
$this->divider = $divider;
86+
8087
return $this;
8188
}
8289

8390
public function multiplier(float $multiplier): self
8491
{
8592
$this->multiplier = $multiplier;
93+
8694
return $this;
8795
}
8896

8997
public function textOrig(bool $textOrig = true): self
9098
{
9199
$this->textOrig = $textOrig;
100+
92101
return $this;
93102
}
94103

95104
public function noTotal(bool $noTotal = true): self
96105
{
97106
$this->nototal = $noTotal;
107+
98108
return $this;
99109
}
100110

101111
public function descrLen(int $descrLen): self
102112
{
103113
$this->descrLen = $descrLen;
114+
104115
return $this;
105116
}
106117

@@ -116,6 +127,7 @@ public function addDataset(
116127
'descr' => $description,
117128
'colour' => $colour,
118129
];
130+
119131
return $this;
120132
}
121133

LibreNMS/Data/Graphing/GraphFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* GraphFactory.php
45
*
@@ -46,7 +47,7 @@ public function graphFor(string $name, array $vars = []): GraphInterface
4647
$vars['type'] ??= $name;
4748

4849
// Look for a modern class, e.g. LibreNMS\Data\Graphing\Device\ProcessorSeparateGraph
49-
$className = "LibreNMS\\Graphs\\" . ucfirst($type) . "\\" . Str::studly($subtype) . "Graph";
50+
$className = 'LibreNMS\\Graphs\\' . ucfirst($type) . '\\' . Str::studly($subtype) . 'Graph';
5051
if (class_exists($className)) {
5152
return app($className, ['vars' => $vars]);
5253
}

LibreNMS/Data/Graphing/LegacyGraph.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* LegacyGraph.php
45
*
@@ -47,6 +48,7 @@ class LegacyGraph extends AbstractGraph
4748

4849
/**
4950
* @param array<string, scalar> $vars
51+
*
5052
* @throws InvalidGraph
5153
*/
5254
public function __construct(
@@ -103,6 +105,7 @@ private function load(): void
103105

104106
if (! $auth) {
105107
$this->loaded = true;
108+
106109
return;
107110
}
108111

@@ -144,19 +147,21 @@ private function load(): void
144147
public function authorize(): bool
145148
{
146149
$this->load();
150+
147151
return $this->authorized;
148152
}
149153

150-
151154
public function definition(GraphParameters $graph_params): array
152155
{
153156
$this->load();
157+
154158
return $this->rrdOptions;
155159
}
156160

157161
public function getPageTitle(): string
158162
{
159163
$this->load();
164+
160165
return $this->pageTitle ?? $this->getGraphTitle();
161166
}
162167

@@ -178,6 +183,7 @@ public function getGraphTitle(): string
178183
public function getRrdFiles(): array
179184
{
180185
$this->load();
186+
181187
return $this->rrdFiles;
182188
}
183189
}

LibreNMS/Exceptions/InvalidGraph.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* InvalidGraph.php
45
*
@@ -29,8 +30,8 @@
2930

3031
class InvalidGraph extends RrdException
3132
{
32-
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
33-
{
34-
parent::__construct($message ?: "Invalid Graph", $code, $previous);
35-
}
33+
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
34+
{
35+
parent::__construct($message ?: 'Invalid Graph', $code, $previous);
36+
}
3637
}

LibreNMS/Graphs/Device/ProcessorGraph.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* ProcessorGraph.php
45
*
@@ -71,6 +72,7 @@ public function getRrdFiles(): array
7172
foreach ($this->processors as $proc) {
7273
$files[] = Rrd::name($this->device->hostname, ['processor', $proc->processor_type, $proc->processor_index]);
7374
}
75+
7476
return $files;
7577
}
7678

LibreNMS/Interfaces/Data/Graphing/GraphInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* GraphInterface.php
45
*
@@ -30,9 +31,14 @@
3031
interface GraphInterface
3132
{
3233
public function authorize(): bool;
34+
3335
public function validation(): array;
36+
3437
public function definition(GraphParameters $graph_params): array;
38+
3539
public function getPageTitle(): string;
40+
3641
public function getGraphTitle(): string;
42+
3743
public function getRrdFiles(): array;
3844
}

app/Console/Commands/GraphDetail.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ public function handle(GraphFactory $graphs): int
2424
$this->line("Type: $graph->type");
2525
$this->line("Subtype: $graph->subtype");
2626
$this->line('Authorized: ' . ($graph->authorize() ? 'true' : 'false'));
27-
$this->line("Graph Title: " . $graph->getGraphTitle());
28-
$this->line("Page Title: " . substr($graph->getPageTitle(), 0, 80));
29-
$this->line("Rrd Files: " . implode(', ', array_map(fn($f) => basename($f), $graph->getRrdFiles())));
30-
$this->line("Definition: " . substr(implode(' ', $graph->definition()), 80));
31-
27+
$this->line('Graph Title: ' . $graph->getGraphTitle());
28+
$this->line('Page Title: ' . substr($graph->getPageTitle(), 0, 80));
29+
$this->line('Rrd Files: ' . implode(', ', array_map(fn ($f) => basename($f), $graph->getRrdFiles())));
30+
$this->line('Definition: ' . substr(implode(' ', $graph->definition()), 80));
3231

3332
return 0;
3433
}

0 commit comments

Comments
 (0)