@@ -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); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | list($option, $delimiter) = [$delimiter, '']; |
148 | 148 | } |
149 | 149 | |
150 | - return implode($delimiter, array_map(function ($pinyin) { |
|
150 | + return implode($delimiter, array_map(function($pinyin) { |
|
151 | 151 | return is_numeric($pinyin) ? $pinyin : mb_substr($pinyin, 0, 1); |
152 | 152 | }, $this->convert($string, $option))); |
153 | 153 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $this->loader = $loader; |
211 | 211 | return $this; |
212 | 212 | } |
213 | - $loader = __NAMESPACE__ . '\\Loaders\\' . Str::studly($loader); |
|
213 | + $loader = __NAMESPACE__.'\\Loaders\\'.Str::studly($loader); |
|
214 | 214 | if (class_exists($loader) && in_array(DictLoader::class, class_implements($loader))) { |
215 | 215 | $this->loader = $loader; |
216 | 216 | return $this; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function setDataPath(?string $path): self |
243 | 243 | { |
244 | - $path = $path ?? dirname(__DIR__) . '/data/'; |
|
244 | + $path = $path ?? dirname(__DIR__).'/data/'; |
|
245 | 245 | if (!is_dir($path)) { |
246 | 246 | throw new InvalidArgumentException(sprintf('\'%s\' is not valid data path.', $path)); |
247 | 247 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $string = $this->convertSurname($string, $dictLoader); |
268 | 268 | } |
269 | 269 | |
270 | - $dictLoader->map(function ($dictionary) use (&$string) { |
|
270 | + $dictLoader->map(function($dictionary) use (&$string) { |
|
271 | 271 | $string = strtr($string, $dictionary); |
272 | 272 | }); |
273 | 273 | |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | */ |
285 | 285 | protected function convertSurname(string $string, DictLoader $dictLoader): string |
286 | 286 | { |
287 | - $dictLoader->mapSurname(function ($dictionary) use (&$string) { |
|
287 | + $dictLoader->mapSurname(function($dictionary) use (&$string) { |
|
288 | 288 | foreach ($dictionary as $surname => $pinyin) { |
289 | 289 | if (0 === strpos($string, $surname)) { |
290 | - $string = $pinyin . mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); |
|
290 | + $string = $pinyin.mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); |
|
291 | 291 | |
292 | 292 | break; |
293 | 293 | } |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | */ |
344 | 344 | protected function prepare(string $string, int $option = self::DEFAULT): string |
345 | 345 | { |
346 | - $string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) { |
|
347 | - return "\t" . $matches[0]; |
|
346 | + $string = preg_replace_callback('~[a-z0-9_-]+~i', function($matches) { |
|
347 | + return "\t".$matches[0]; |
|
348 | 348 | }, $string); |
349 | 349 | |
350 | 350 | $regex = ['\p{Han}', '\p{Z}', '\p{M}', "\t"]; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $umlaut = 'v'; |
394 | 394 | } |
395 | 395 | |
396 | - $pinyin = str_replace($unicode, $umlaut, $pinyin) . ($this->hasOption($option, self::ASCII_TONE) ? $replacement[1] : ''); |
|
396 | + $pinyin = str_replace($unicode, $umlaut, $pinyin).($this->hasOption($option, self::ASCII_TONE) ? $replacement[1] : ''); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 |