blob: f5e0e2aef9a36352d8d0b2b9d652166546c09d42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?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, sprintf('<?php return %s;'.PHP_EOL,
$exported
));
}
}
|