MetricsController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 49
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 24 1
A logs() 0 4 1
A logShow() 0 16 2
1
<?php
2
3
namespace Tracking\Http\Controllers\Metrics;
4
5
use Illuminate\Http\Request;
6
use Tracking\Http\Controllers\Controller as Controller;
7
use Tracking\Models\Metrics\LarametricsLog;
8
use Tracking\Models\Metrics\LarametricsModel;
9
use Tracking\Models\Metrics\LarametricsRequest;
10
use Tracking\Providers\Metrics\LogParser;
11
12
class MetricsController extends Controller
13
{
14
    public function index()
15
    {
16
        $requests = LarametricsRequest::orderBy('created_at', 'desc')
17
            ->limit(10)
18
            ->get();
19
20
        $logs = LarametricsLog::orderBy('created_at', 'desc')
21
            ->limit(10)
22
            ->get();
23
24
        $models = LarametricsModel::orderBy('created_at', 'desc')
25
            ->limit(10)
26
            ->get();
27
28
        return $this->populateView(
0 ignored issues
show
Documentation Bug introduced by
The method populateView does not exist on object<Tracking\Http\Con...rics\MetricsController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
29
            'tracking::larametrics.metrics.index',
30
            [
31
            'pageTitle' => 'Dashboard',
32
            'requests' => $requests,
33
            'logs' => $logs,
34
            'models' => $models
35
            ]
36
        );
37
    }
38
39
    public function logs()
40
    {
41
        return $this->populateView('tracking::larametrics.logs.index');
0 ignored issues
show
Documentation Bug introduced by
The method populateView does not exist on object<Tracking\Http\Con...rics\MetricsController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
42
    }
43
44
    public function logShow($index)
45
    {
46
        $logArray = LogParser::all();
47
48
        if (!isset($logArray[$index])) {
49
            return abort(404);
50
        }
51
52
        return $this->populateView(
0 ignored issues
show
Documentation Bug introduced by
The method populateView does not exist on object<Tracking\Http\Con...rics\MetricsController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
53
            'tracking::larametrics.logs.show',
54
            [
55
            'log' => $logArray[$index],
56
            'pageTitle' => 'Viewing Log'
57
            ]
58
        );
59
    }
60
}
61