LumenController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
0 ignored issues
show
Coding Style introduced by
Filename "LumenController.php" doesn't match the expected filename "lumencontroller.php"
Loading history...
2
namespace Triadev\PrometheusExporter\Controller;
3
4
use Illuminate\Http\Response;
5
use Prometheus\RenderTextFormat;
6
use Triadev\PrometheusExporter\PrometheusExporter;
7
use Laravel\Lumen\Routing\Controller;
8
9
class LumenController extends Controller
10
{
11
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
12
     * @var PrometheusExporter
13
     */
14
    protected $prometheusExporter;
0 ignored issues
show
Coding Style introduced by
Protected member variable "prometheusExporter" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
15
16
    /**
17
     * PrometheusExporterController constructor.
18
     *
19
     * @param PrometheusExporter $prometheusExporter
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
20
     */
21
    public function __construct(PrometheusExporter $prometheusExporter)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
22
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
23
        $this->prometheusExporter = $prometheusExporter;
24
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __construct()
Loading history...
25
26
    /**
27
     * metrics
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
28
     *
29
     * Expose metrics for prometheus
30
     *
31
     * @return Response
32
     */
33
    public function metrics() : Response
34
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
35
        $renderer = new RenderTextFormat();
36
        
37
        return \response()->make(
38
            $renderer->render($this->prometheusExporter->getMetricFamilySamples())
39
        )->header('Content-Type', RenderTextFormat::MIME_TYPE);
40
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end metrics()
Loading history...
41
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
42