LaravelController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A metrics() 0 7 1
A __construct() 0 3 1
1
<?php
0 ignored issues
show
Coding Style introduced by
Filename "LaravelController.php" doesn't match the expected filename "laravelcontroller.php"
Loading history...
2
namespace Triadev\PrometheusExporter\Controller;
3
4
use Illuminate\Http\Response;
5
use Illuminate\Routing\Controller;
6
use Prometheus\RenderTextFormat;
7
use Triadev\PrometheusExporter\PrometheusExporter;
8
9
class LaravelController 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::create(
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