* Load the snapshot from disk, or return null if missing or invalid. */
(string $sourceId = '')
| 550 | * Load the snapshot from disk, or return null if missing or invalid. |
| 551 | */ |
| 552 | public static function loadSnapshot(string $sourceId = ''): ?array |
| 553 | { |
| 554 | $path = self::snapshotPath($sourceId); |
| 555 | if (!is_file($path)) { |
| 556 | return null; |
| 557 | } |
| 558 | $raw = @file_get_contents($path); |
| 559 | if ($raw === false || $raw === '') { |
| 560 | return null; |
| 561 | } |
| 562 | $data = json_decode($raw, true); |
| 563 | if (!is_array($data)) { |
| 564 | return null; |
| 565 | } |
| 566 | if (!isset($data['version']) || (int)$data['version'] !== 1) { |
| 567 | return null; |
| 568 | } |
| 569 | return $data; |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * Compute a lightweight summary for the Admin panel. |
no test coverage detected