1 | <?php |
||
10 | class DatabaseStore implements StatisticsStore |
||
11 | { |
||
12 | /** |
||
13 | * The model that will interact with the database. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | public static $model = \BeyondCode\LaravelWebSockets\Models\WebSocketsStatisticsEntry::class; |
||
18 | |||
19 | /** |
||
20 | * Store a new record in the database and return |
||
21 | * the created instance. |
||
22 | * |
||
23 | * @param array $data |
||
24 | * @return mixed |
||
25 | */ |
||
26 | public static function store(array $data) |
||
30 | |||
31 | /** |
||
32 | * Delete records older than the given moment, |
||
33 | * for a specific app id (if given), returning |
||
34 | * the amount of deleted records. |
||
35 | * |
||
36 | * @param \Carbon\Carbon $moment |
||
37 | * @param string|int|null $appId |
||
38 | * @return int |
||
39 | */ |
||
40 | public static function delete(Carbon $moment, $appId = null): int |
||
48 | |||
49 | /** |
||
50 | * Get the query result as eloquent collection. |
||
51 | * |
||
52 | * @param callable $processQuery |
||
53 | * @return \Illuminate\Support\Collection |
||
54 | */ |
||
55 | public function getRawRecords(callable $processQuery = null) |
||
64 | |||
65 | /** |
||
66 | * Get the results for a specific query. |
||
67 | * |
||
68 | * @param callable $processQuery |
||
69 | * @param callable $processCollection |
||
70 | * @return array |
||
71 | */ |
||
72 | public function getRecords(callable $processQuery = null, callable $processCollection = null): array |
||
83 | |||
84 | /** |
||
85 | * Get the results for a specific query into a |
||
86 | * format that is easily to read for graphs. |
||
87 | * |
||
88 | * @param callable $processQuery |
||
89 | * @return array |
||
90 | */ |
||
91 | public function getForGraph(callable $processQuery = null): array |
||
99 | |||
100 | /** |
||
101 | * Turn the statistic model to an array. |
||
102 | * |
||
103 | * @param \Illuminate\Database\Eloquent\Model $statistic |
||
104 | * @return array |
||
105 | */ |
||
106 | protected function statisticToArray(Model $statistic): array |
||
115 | |||
116 | /** |
||
117 | * Turn the statistics collection to an array used for graph. |
||
118 | * |
||
119 | * @param \Illuminate\Support\Collection $statistics |
||
120 | * @return array |
||
121 | */ |
||
122 | protected function statisticsToGraph(Collection $statistics): array |
||
139 | } |
||
140 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.