| 1: | <?php |
| 2: | |
| 3: | namespace LaravelUi5\Core\Ui5\Contracts; |
| 4: | |
| 5: | use LaravelUi5\Core\Enums\AggregationLevel; |
| 6: | |
| 7: | /** |
| 8: | * Contract for KPI data providers delivering live metric values. |
| 9: | * |
| 10: | * Implementations must return a valid associative array that represents |
| 11: | * a complete KPI snapshot suitable for rendering inside UI5 dashboards. |
| 12: | * |
| 13: | * A provider receives the aggregation level (e.g., monthly, weekly) and |
| 14: | * a set of context parameters (e.g. 'project_id' => 42) to produce the data. |
| 15: | */ |
| 16: | interface KpiProviderInterface |
| 17: | { |
| 18: | /** |
| 19: | * Returns the data payload for the KPI tile. |
| 20: | * |
| 21: | * The returned array should match the expected UI5 JSON structure, |
| 22: | * typically including keys such as 'value', 'valueColor', 'indicator', |
| 23: | * 'unit', 'scale', and optionally a trend or target. |
| 24: | * |
| 25: | * @param AggregationLevel $aggregationLevel Level of data grouping (daily, weekly, etc.) |
| 26: | * @param array<string, mixed> $context Contextual filters like project ID, year, etc. |
| 27: | * |
| 28: | * @return array<string, mixed> KPI payload as an associative array |
| 29: | */ |
| 30: | public function toJson(AggregationLevel $aggregationLevel, array $context): array; |
| 31: | } |
| 32: |