appId = $appId; } public function isEnabled(): bool { return App::findById($this->appId)->statisticsEnabled; } public function logConnection() { $this->currentConnectionCount++; $this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount); } public function logDisconnection() { $this->currentConnectionCount--; $this->peakConnectionCount = max($this->currentConnectionCount, $this->peakConnectionCount); } public function logWebSocketMessage() { $this->webSocketMessageCount++; } public function logApiMessage() { $this->apiMessageCount++; } public function reset(int $currentConnectionCount) { $this->currentConnectionCount = $currentConnectionCount; $this->peakConnectionCount = $currentConnectionCount; $this->webSocketMessageCount = 0; $this->apiMessageCount = 0; } public function toArray() { return [ 'app_id' => $this->appId, 'peak_connection_count' => $this->peakConnectionCount, 'websocket_message_count' => $this->webSocketMessageCount, 'api_message_count' => $this->apiMessageCount, ]; } }