Completed
Pull Request — master (#447)
by Alexandru
10:50 queued 02:32
created

ShowStatistics   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 1
1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers;
4
5
use BeyondCode\LaravelWebSockets\Facades\StatisticsStore;
6
use Illuminate\Http\Request;
7
8
class ShowStatistics
9
{
10
    /**
11
     * Get statistics for an app ID.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @param  mixed  $appId
15
     * @return \Illuminate\Http\Response
16
     */
17
    public function __invoke(Request $request, $appId)
18
    {
19
        $processQuery = function ($query) use ($appId) {
20
            return $query->whereAppId($appId)
21
                ->latest()
22
                ->limit(120);
23
        };
24
25
        $processCollection = function ($collection) {
26
            return $collection->reverse();
27
        };
28
29
        return StatisticsStore::getForGraph(
30
            $processQuery, $processCollection
31
        );
32
    }
33
}
34