DatabasePanel::connection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
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