HomeController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 8
c 2
b 1
f 0
dl 0
loc 18
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A chart() 0 11 1
A dashboard() 0 3 1
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use App\Http\Controllers\Controller;
6
use App\Services\SolutionService;
7
use App\Services\UserService;
8
use Carbon\Carbon;
9
10
class HomeController extends Controller
11
{
12
    public function dashboard()
13
    {
14
        return view('admin.app');
15
    }
16
17
    public function chart()
18
    {
19
        $result = [];
20
21
        $from = Carbon::create(null, null, null, 0, 0, 0);
22
        $from = $from->subDays(request('from'));
0 ignored issues
show
Bug introduced by
request('from') of type Illuminate\Http\Request|array|string is incompatible with the type integer expected by parameter $value of Carbon\Carbon::subDays(). ( Ignorable by Annotation )

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

22
        $from = $from->subDays(/** @scrutinizer ignore-type */ request('from'));
Loading history...
23
24
        $result['user'] = app(UserService::class)->getUserStats($from);
0 ignored issues
show
Bug introduced by
It seems like $from can also be of type false; however, parameter $from of App\Services\UserService::getUserStats() does only seem to accept Carbon\Carbon, maybe add an additional type check? ( Ignorable by Annotation )

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

24
        $result['user'] = app(UserService::class)->getUserStats(/** @scrutinizer ignore-type */ $from);
Loading history...
25
        $result['submission'] = app(SolutionService::class)->getSubmissionStats($from);
0 ignored issues
show
Bug introduced by
It seems like $from can also be of type false; however, parameter $from of App\Services\SolutionService::getSubmissionStats() does only seem to accept Carbon\Carbon, maybe add an additional type check? ( Ignorable by Annotation )

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

25
        $result['submission'] = app(SolutionService::class)->getSubmissionStats(/** @scrutinizer ignore-type */ $from);
Loading history...
26
27
        return $result;
28
    }
29
}
30