summaryrefslogtreecommitdiff
path: root/src/Build/NameHandler.php
diff options
context:
space:
mode:
authorZhineng Li <[email protected]>2026-01-21 15:36:56 +0800
committerZhineng Li <[email protected]>2026-01-21 15:37:00 +0800
commit80b213ca56e6b9de54fa10b489637be60c4c7141 (patch)
tree1760503493e92af724bb2f6fecc202db6ee836c4 /src/Build/NameHandler.php
parent243fa3bfc3be95e29915b96246e8ce1d111dfe38 (diff)
downloadregion-china-80b213ca56e6b9de54fa10b489637be60c4c7141.tar.gz
region-china-80b213ca56e6b9de54fa10b489637be60c4c7141.zip
rename handler
Diffstat (limited to 'src/Build/NameHandler.php')
-rw-r--r--src/Build/NameHandler.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Build/NameHandler.php b/src/Build/NameHandler.php
new file mode 100644
index 0000000..4661eac
--- /dev/null
+++ b/src/Build/NameHandler.php
@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Zhineng\RegionChina\Build;
+
+use Symfony\Component\VarExporter\VarExporter;
+
+final class NameHandler implements RegionHandler
+{
+ /**
+ * A map of region codes to region names.
+ *
+ * @var array<int, string>
+ */
+ private array $data = [];
+
+ public function handle(string $code, string $name): void
+ {
+ $this->data['_'.$code] = $name;
+ }
+
+ public function export(string $destination): void
+ {
+ $exported = VarExporter::export($this->data);
+
+ file_put_contents($destination, '<?php return '.$exported.';');
+ }
+}