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

TotalUniqueUsersBoxComposer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 35
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A compose() 0 16 1
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