Completed
Pull Request — master (#447)
by Alexandru
01:27
created

ShowStatistics::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 2
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