Completed
Push — master ( fecc61...f6dbaa )
by ARCANEDEV
04:52
created

TotalPageViewsBoxComposer::compose()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
crap 2
1
<?php namespace Arcanesoft\Tracker\ViewComposers\Dashboard;
2
3
use Arcanesoft\Tracker\Models\SessionActivity;
4
use Arcanesoft\Tracker\Support\DateRange;
5
use Arcanesoft\Tracker\ViewComposers\AbstractViewComposer;
6
use Illuminate\Contracts\View\View;
7
8
/**
9
 * Class     TotalPageViewsBoxComposer
10
 *
11
 * @package  Arcanesoft\Tracker\ViewComposers\Dashboard
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class TotalPageViewsBoxComposer extends AbstractViewComposer
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Constants
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
    const VIEW = 'tracker::foundation._composers.dashboard.total-page-views-box';
21
22
    /* ------------------------------------------------------------------------------------------------
23
     |  Main Functions
24
     | ------------------------------------------------------------------------------------------------
25
     */
26
    /**
27
     * Compose the view.
28
     *
29
     * @param  \Illuminate\Contracts\View\View  $view
30
     */
31
    public function compose(View $view)
32
    {
33
        /**
34
         * @var  \Carbon\Carbon                  $start
35
         * @var  \Carbon\Carbon                  $end
36
         * @var  \Illuminate\Support\Collection  $range
37
         */
38
        extract(DateRange::getCurrentMonthDaysRange());
0 ignored issues
show
Bug introduced by
\Arcanesoft\Tracker\Supp...CurrentMonthDaysRange() cannot be passed to extract() as the parameter $var_array expects a reference.
Loading history...
39
40
        $visits = $this->getCachedVisits()
41
            ->filter(function (SessionActivity $activity) use ($start, $end) {
42
                return $activity->created_at->between($start, $end);
43
            });
44
45
        $view->with('pageViewsCount', $visits->count());
46
    }
47
}
48