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