Skip to content

Commit f62d86f

Browse files
committed
Apply fixes from StyleCI
1 parent f0c939f commit f62d86f

9 files changed

Lines changed: 51 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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* MultiLineGraphBuilder.php
45
*
@@ -45,48 +46,56 @@ class MultiLineGraphBuilder
4546
public function unitText(string $unitText): self
4647
{
4748
$this->unitText = $unitText;
49+
4850
return $this;
4951
}
5052

5153
public function units(string $units): self
5254
{
5355
$this->units = $units;
56+
5457
return $this;
5558
}
5659

5760
public function totalUnits(string $totalUnits): self
5861
{
5962
$this->totalUnits = $totalUnits;
63+
6064
return $this;
6165
}
6266

6367
public function colours(string $colours): self
6468
{
6569
$this->colours = $colours;
70+
6671
return $this;
6772
}
6873

6974
public function scaleMin(float $scaleMin): self
7075
{
7176
$this->scaleMin = $scaleMin;
77+
7278
return $this;
7379
}
7480

7581
public function scaleMax(float $scaleMax): self
7682
{
7783
$this->scaleMax = $scaleMax;
84+
7885
return $this;
7986
}
8087

8188
public function noTotal(bool $noTotal = true): self
8289
{
8390
$this->nototal = $noTotal;
91+
8492
return $this;
8593
}
8694

8795
public function descrLen(int $descrLen): self
8896
{
8997
$this->descrLen = $descrLen;
98+
9099
return $this;
91100
}
92101

@@ -108,6 +117,7 @@ public function addDataset(
108117
'areacolour' => $areaColour,
109118
'invert' => $invert,
110119
];
120+
111121
return $this;
112122
}
113123

LibreNMS/Data/Graphing/Builders/MultiSimplexSeparatedGraphBuilder.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* MultiSimplexSeparatedGraphBuilder.php
45
*
@@ -48,66 +49,77 @@ class MultiSimplexSeparatedGraphBuilder
4849
public function unitText(string $unitText): self
4950
{
5051
$this->unitText = $unitText;
52+
5153
return $this;
5254
}
5355

5456
public function units(string $units): self
5557
{
5658
$this->units = $units;
59+
5760
return $this;
5861
}
5962

6063
public function totalUnits(string $totalUnits): self
6164
{
6265
$this->totalUnits = $totalUnits;
66+
6367
return $this;
6468
}
6569

6670
public function colours(string $colours): self
6771
{
6872
$this->colours = $colours;
73+
6974
return $this;
7075
}
7176

7277
public function scaleMin(float $scaleMin): self
7378
{
7479
$this->scaleMin = $scaleMin;
80+
7581
return $this;
7682
}
7783

7884
public function scaleMax(float $scaleMax): self
7985
{
8086
$this->scaleMax = $scaleMax;
87+
8188
return $this;
8289
}
8390

8491
public function divider(float $divider): self
8592
{
8693
$this->divider = $divider;
94+
8795
return $this;
8896
}
8997

9098
public function multiplier(float $multiplier): self
9199
{
92100
$this->multiplier = $multiplier;
101+
93102
return $this;
94103
}
95104

96105
public function textOrig(bool $textOrig = true): self
97106
{
98107
$this->textOrig = $textOrig;
108+
99109
return $this;
100110
}
101111

102112
public function noTotal(bool $noTotal = true): self
103113
{
104114
$this->nototal = $noTotal;
115+
105116
return $this;
106117
}
107118

108119
public function descrLen(int $descrLen): self
109120
{
110121
$this->descrLen = $descrLen;
122+
111123
return $this;
112124
}
113125

@@ -123,6 +135,7 @@ public function addDataset(
123135
'descr' => $description,
124136
'colour' => $colour,
125137
];
138+
126139
return $this;
127140
}
128141

LibreNMS/Data/Graphing/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/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
*
@@ -45,7 +46,7 @@ public function graphFor(string $name, array $vars = []): GraphInterface
4546
$vars['type'] ??= $name;
4647

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

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
*
@@ -29,6 +30,7 @@
2930
use App\Models\Device;
3031
use App\Models\Port;
3132
use LibreNMS\Exceptions\InvalidGraph;
33+
3234
use function base_path;
3335

3436
class LegacyGraph extends AbstractGraph
@@ -104,6 +106,7 @@ private function load(array $vars = []): void
104106

105107
if (! $auth) {
106108
$this->loaded = true;
109+
107110
return;
108111
}
109112

@@ -145,19 +148,21 @@ private function load(array $vars = []): void
145148
public function authorize(): bool
146149
{
147150
$this->load();
151+
148152
return $this->authorized;
149153
}
150154

151-
152155
public function definition(GraphParameters $graph_params): array
153156
{
154157
$this->load($graph_params->all());
158+
155159
return $this->rrdOptions;
156160
}
157161

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

@@ -179,6 +184,7 @@ public function getGraphTitle(): string
179184
public function getRrdFiles(): array
180185
{
181186
$this->load();
187+
182188
return $this->rrdFiles;
183189
}
184190
}

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/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)