diff options
Diffstat (limited to 'src/Build/NameHandler.php')
| -rw-r--r-- | src/Build/NameHandler.php | 29 |
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.';'); + } +} |
