@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | list($option, $delimiter) = [$delimiter, '']; |
145 | 145 | } |
146 | 146 | |
147 | - return implode($delimiter, array_map(function ($pinyin) { |
|
147 | + return implode($delimiter, array_map(function($pinyin) { |
|
148 | 148 | return is_numeric($pinyin) ? $pinyin : mb_substr($pinyin, 0, 1); |
149 | 149 | }, $this->convert($string, $option))); |
150 | 150 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function setDataPath(?string $path): self |
229 | 229 | { |
230 | - $path = $path ?? dirname(__DIR__) . '/data/'; |
|
230 | + $path = $path ?? dirname(__DIR__).'/data/'; |
|
231 | 231 | if (!is_dir($path)) { |
232 | 232 | throw new InvalidArgumentException(sprintf('\'%s\' is not valid data path.', $path)); |
233 | 233 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $string = $this->convertSurname($string, $dictLoader); |
253 | 253 | } |
254 | 254 | |
255 | - $dictLoader->map(function ($dictionary) use (&$string) { |
|
255 | + $dictLoader->map(function($dictionary) use (&$string) { |
|
256 | 256 | $string = strtr($string, $dictionary); |
257 | 257 | }); |
258 | 258 | |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | */ |
270 | 270 | protected function convertSurname(string $string, DictLoader $dictLoader): string |
271 | 271 | { |
272 | - $dictLoader->mapSurname(function ($dictionary) use (&$string) { |
|
272 | + $dictLoader->mapSurname(function($dictionary) use (&$string) { |
|
273 | 273 | foreach ($dictionary as $surname => $pinyin) { |
274 | 274 | if (0 === strpos($string, $surname)) { |
275 | - $string = $pinyin . mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); |
|
275 | + $string = $pinyin.mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); |
|
276 | 276 | |
277 | 277 | break; |
278 | 278 | } |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | */ |
325 | 325 | protected function prepare(string $string, int $option = self::DEFAULT): string |
326 | 326 | { |
327 | - $string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) { |
|
328 | - return "\t" . $matches[0]; |
|
327 | + $string = preg_replace_callback('~[a-z0-9_-]+~i', function($matches) { |
|
328 | + return "\t".$matches[0]; |
|
329 | 329 | }, $string); |
330 | 330 | |
331 | 331 | $regex = ['\p{Han}', '\p{Z}', '\p{M}', "\t"]; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $umlaut = 'v'; |
375 | 375 | } |
376 | 376 | |
377 | - $pinyin = str_replace($unicode, $umlaut, $pinyin) . ($this->hasOption($option, self::ASCII_TONE) ? $replacement[1] : ''); |
|
377 | + $pinyin = str_replace($unicode, $umlaut, $pinyin).($this->hasOption($option, self::ASCII_TONE) ? $replacement[1] : ''); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->path = $path; |
59 | 59 | |
60 | 60 | for ($i = 0; $i < 100; ++$i) { |
61 | - $segment = $this->path . '/' . sprintf($this->segmentName, $i); |
|
61 | + $segment = $this->path.'/'.sprintf($this->segmentName, $i); |
|
62 | 62 | |
63 | 63 | if (file_exists($segment) && is_file($segment)) { |
64 | 64 | array_push(static::$handles, $this->openFile($segment)); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public function mapSurname(Closure $callback) |
138 | 138 | { |
139 | 139 | if (!static::$surnamesHandle instanceof SplFileObject) { |
140 | - static::$surnamesHandle = $this->openFile($this->path . '/surnames'); |
|
140 | + static::$surnamesHandle = $this->openFile($this->path.'/surnames'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | $this->traversing($this->getGenerator([static::$surnamesHandle]), $callback); |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | $this->path = $path; |
57 | 57 | |
58 | 58 | for ($i = 0; $i < 100; ++$i) { |
59 | - $segment = $path . '/' . sprintf($this->segmentName, $i); |
|
59 | + $segment = $path.'/'.sprintf($this->segmentName, $i); |
|
60 | 60 | |
61 | 61 | if (file_exists($segment)) { |
62 | - $this->segments[] = (array)include $segment; |
|
62 | + $this->segments[] = (array) include $segment; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | public function mapSurname(Closure $callback) |
85 | 85 | { |
86 | 86 | if (empty($this->surnames)) { |
87 | - $surnames = $this->path . '/surnames'; |
|
87 | + $surnames = $this->path.'/surnames'; |
|
88 | 88 | |
89 | 89 | if (file_exists($surnames)) { |
90 | - $this->surnames = (array)include $surnames; |
|
90 | + $this->surnames = (array) include $surnames; |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | public function map(Closure $callback) |
50 | 50 | { |
51 | 51 | for ($i = 0; $i < 100; ++$i) { |
52 | - $segment = $this->path . '/' . sprintf($this->segmentName, $i); |
|
52 | + $segment = $this->path.'/'.sprintf($this->segmentName, $i); |
|
53 | 53 | |
54 | 54 | if (file_exists($segment)) { |
55 | - $dictionary = (array)include $segment; |
|
55 | + $dictionary = (array) include $segment; |
|
56 | 56 | $callback($dictionary); |
57 | 57 | } |
58 | 58 | } |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function mapSurname(Closure $callback) |
67 | 67 | { |
68 | - $surnames = $this->path . '/surnames'; |
|
68 | + $surnames = $this->path.'/surnames'; |
|
69 | 69 | |
70 | 70 | if (file_exists($surnames)) { |
71 | - $dictionary = (array)include $surnames; |
|
71 | + $dictionary = (array) include $surnames; |
|
72 | 72 | $callback($dictionary); |
73 | 73 | } |
74 | 74 | } |