DatabasePanel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 28
ccs 0
cts 10
cp 0
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A connection() 0 3 1
A render() 0 6 1
A getDatabaseStats() 0 7 2
1
<?php
2
3
namespace Terranet\Administrator\Dashboard\Panels;
4
5
use Terranet\Administrator\Architect;
6
use Terranet\Administrator\Dashboard\Panel;
7
use Terranet\Administrator\Traits\Stringify;
8
use function admin\db\connection;
9
10
class DatabasePanel extends Panel
11
{
12
    use Stringify;
13
14
    public function render()
15
    {
16
        $dbStats = $this->getDatabaseStats();
17
18
        return view(Architect::template()->dashboard('database'), [
0 ignored issues
show
Bug introduced by
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        return /** @scrutinizer ignore-call */ view(Architect::template()->dashboard('database'), [
Loading history...
19
            'dbStats' => $dbStats,
20
        ]);
21
    }
22
23
    /**
24
     * @return mixed
25
     */
26
    protected function getDatabaseStats()
27
    {
28
        if (connection('mysql')) {
29
            return $this->connection()->select($this->connection()->raw('SHOW TABLE STATUS'));
30
        }
31
32
        return collect([]);
33
    }
34
35
    protected function connection()
36
    {
37
        return app('db');
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        return /** @scrutinizer ignore-call */ app('db');
Loading history...
38
    }
39
}
40