summaryrefslogtreecommitdiff
path: root/src/Build/TopLevelHandler.php
diff options
context:
space:
mode:
authorLi Zhineng <[email protected]>2025-04-28 17:20:39 +0800
committerLi Zhineng <[email protected]>2025-04-28 17:20:39 +0800
commit5aca6a5eef938b1fdedb4d14f5f7edcac91b5215 (patch)
tree0ad65fe3724d29e98ae352eac0487138f05035c6 /src/Build/TopLevelHandler.php
downloadregion-china-5aca6a5eef938b1fdedb4d14f5f7edcac91b5215.tar.gz
region-china-5aca6a5eef938b1fdedb4d14f5f7edcac91b5215.zip
build data from raw html
Diffstat (limited to 'src/Build/TopLevelHandler.php')
-rw-r--r--src/Build/TopLevelHandler.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Build/TopLevelHandler.php b/src/Build/TopLevelHandler.php
new file mode 100644
index 0000000..a0c7f10
--- /dev/null
+++ b/src/Build/TopLevelHandler.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Zhineng\Region\Build;
+
+use Symfony\Component\VarExporter\VarExporter;
+
+final class TopLevelHandler implements RegionHandler
+{
+ /**
+ * @var int[]
+ */
+ private array $data = [];
+
+ public function handle(string $code, string $name): void
+ {
+ if (substr($code, -4) !== '0000') {
+ return;
+ }
+
+ $this->data[] = (int) $code;
+ }
+
+ public function export(string $destination): void
+ {
+ $exported = VarExporter::export($this->data);
+
+ file_put_contents($destination, '<?php return '.$exported.';');
+ }
+}