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

TotalUniqueUsersBoxComposer::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\Session;
4
use Arcanesoft\Tracker\Support\DateRange;
5
use Arcanesoft\Tracker\ViewComposers\AbstractViewComposer;
6
use Illuminate\Contracts\View\View;
7
8
/**
9
 * Class     TotalUniqueUsersBoxComposer
10
 *
11
 * @package  Arcanesoft\Tracker\ViewComposers\Dashboard
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
class TotalUniqueUsersBoxComposer extends AbstractViewComposer
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Constants
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
21
    const VIEW = 'tracker::foundation._composers.dashboard.total-unique-visitors-box';
22
23
    /* ------------------------------------------------------------------------------------------------
24
     |  Main Functions
25
     | ------------------------------------------------------------------------------------------------
26
     */
27
    /**
28
     * Compose the view.
29
     *
30
     * @param  \Illuminate\Contracts\View\View  $view
31
     */
32
    public function compose(View $view)
33
    {
34
        /**
35
         * @var  \Carbon\Carbon                  $start
36
         * @var  \Carbon\Carbon                  $end
37
         * @var  \Illuminate\Support\Collection  $range
38
         */
39
        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...
40
41
        $visitors = $this->getCachedVisitors()
42
            ->filter(function (Session $visitor) use ($start, $end) {
43
                return $visitor->updated_at->between($start, $end);
44
            });
45
46
        $view->with('uniqueUsersCount', $visitors->count());
47
    }
48
}
49