>|null */ private static ?array $memo = null; private static bool $loaded = false; /** * @return array>|null null = سوپرادمین در دسترس نبود */ public function map(): ?array { if (self::$loaded) { return self::$memo; } self::$loaded = true; $items = app(SuperAdminProgramSettingsClient::class)->fetchItems(); if ($items === null) { self::$memo = null; return null; } $map = []; foreach ($items as $row) { if (! is_array($row)) { continue; } $key = trim((string) ($row['key'] ?? '')); if ($key === '' || in_array($key, self::LOCAL_OWNED_KEYS, true) || in_array($key, self::RUNTIME_KEYS, true)) { continue; } $map[$key] = $row; } self::$memo = $map; return $map; } /** * @return array> */ public function items(): array { $map = $this->map(); if ($map === null || $map === []) { return []; } return array_values($map); } /** * @return array|null */ public function row(string $key): ?array { $map = $this->map(); if ($map === null) { return null; } $key = trim($key); if ($key === '' || ! array_key_exists($key, $map)) { return null; } return $map[$key]; } public static function isRuntime(string $key): bool { return in_array($key, self::RUNTIME_KEYS, true); } public static function isLocalOwned(string $key): bool { return in_array($key, self::LOCAL_OWNED_KEYS, true); } }