, * destination_url: ?string, * color: string, * }> */ public array $metrics = []; /** * @param array, * destination_url: ?string, * color: string, * }> $metrics */ public function mount(array $metrics = []): void { $this->metrics = $metrics; } /** * @return array */ protected function getStats(): array { return collect($this->metrics) ->map(function (array $metric): Stat { $stat = Stat::make($metric['label'], $metric['value']) ->description($metric['description']) ->color($metric['color']); $destination = $metric['destination'] ?? null; $destinationUrl = is_array($destination) && ($destination['disabled'] ?? false) === false ? ($destination['url'] ?? null) : ($metric['destination_url'] ?? null); if (is_string($destinationUrl) && $destinationUrl !== '') { $stat->url($destinationUrl); } return $stat; }) ->all(); } }