@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | list($option, $delimiter) = [$delimiter, '']; |
155 | 155 | } |
156 | 156 | |
157 | - return implode($delimiter, array_map(function ($pinyin) { |
|
157 | + return implode($delimiter, array_map(function($pinyin) { |
|
158 | 158 | return is_numeric($pinyin) ? $pinyin : mb_substr($pinyin, 0, 1); |
159 | 159 | }, $this->convert($string, $option))); |
160 | 160 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function setPath(?string $path): self |
260 | 260 | { |
261 | - $path = $path ?? dirname(__DIR__) . '/data/'; |
|
261 | + $path = $path ?? dirname(__DIR__).'/data/'; |
|
262 | 262 | if (!is_dir($path)) { |
263 | 263 | throw new InvalidArgumentException(sprintf('\'%s\' is not valid data path.', $path)); |
264 | 264 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $string = $this->convertSurname($string, $dictLoader); |
285 | 285 | } |
286 | 286 | |
287 | - $dictLoader->map(function ($dictionary) use (&$string) { |
|
287 | + $dictLoader->map(function($dictionary) use (&$string) { |
|
288 | 288 | $string = strtr($string, $dictionary); |
289 | 289 | }); |
290 | 290 | |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | */ |
302 | 302 | protected function convertSurname(string $string, DictLoader $dictLoader): string |
303 | 303 | { |
304 | - $dictLoader->mapSurname(function ($dictionary) use (&$string) { |
|
304 | + $dictLoader->mapSurname(function($dictionary) use (&$string) { |
|
305 | 305 | foreach ($dictionary as $surname => $pinyin) { |
306 | 306 | if (0 === strpos($string, $surname)) { |
307 | - $string = $pinyin . mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); |
|
307 | + $string = $pinyin.mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); |
|
308 | 308 | |
309 | 309 | break; |
310 | 310 | } |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | */ |
361 | 361 | protected function prepare(string $string, int $option = self::DEFAULT): string |
362 | 362 | { |
363 | - $string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) { |
|
364 | - return "\t" . $matches[0]; |
|
363 | + $string = preg_replace_callback('~[a-z0-9_-]+~i', function($matches) { |
|
364 | + return "\t".$matches[0]; |
|
365 | 365 | }, $string); |
366 | 366 | |
367 | 367 | $regex = ['\p{Han}', '\p{Z}', '\p{M}', "\t"]; |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $umlaut = 'v'; |
411 | 411 | } |
412 | 412 | |
413 | - $pinyin = str_replace($unicode, $umlaut, $pinyin) . ($this->hasOption($option, self::ASCII_TONE) ? $replacement[1] : ''); |
|
413 | + $pinyin = str_replace($unicode, $umlaut, $pinyin).($this->hasOption($option, self::ASCII_TONE) ? $replacement[1] : ''); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 |
@@ -49,14 +49,14 @@ |
||
49 | 49 | */ |
50 | 50 | public function __construct($path) |
51 | 51 | { |
52 | - $segments = glob($path . '/' . $this->segmentName); |
|
52 | + $segments = glob($path.'/'.$this->segmentName); |
|
53 | 53 | if ($segments == false) { |
54 | 54 | throw new PinyinException('CC-CEDICT dictionary data does not exist'); |
55 | 55 | } |
56 | 56 | while (($segment = array_shift($segments))) { |
57 | 57 | array_push(static::$handles, $this->openFile($segment)); |
58 | 58 | } |
59 | - static::$surnamesHandle = $this->openFile($path . '/surnames'); |
|
59 | + static::$surnamesHandle = $this->openFile($path.'/surnames'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function map(Closure $callback) |
53 | 53 | { |
54 | - $segments = glob($this->path . '/' . $this->segmentName); |
|
54 | + $segments = glob($this->path.'/'.$this->segmentName); |
|
55 | 55 | if ($segments == false) { |
56 | 56 | throw new PinyinException('CC-CEDICT dictionary data does not exist'); |
57 | 57 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function mapSurname(Closure $callback) |
70 | 70 | { |
71 | - $surnames = $this->path . '/surnames'; |
|
71 | + $surnames = $this->path.'/surnames'; |
|
72 | 72 | |
73 | 73 | if (file_exists($surnames)) { |
74 | 74 | $dictionary = Arr::wrap(include $surnames); |
@@ -49,14 +49,14 @@ |
||
49 | 49 | */ |
50 | 50 | public function __construct($path) |
51 | 51 | { |
52 | - $segments = glob($path . '/' . $this->segmentName); |
|
52 | + $segments = glob($path.'/'.$this->segmentName); |
|
53 | 53 | if ($segments == false) { |
54 | 54 | throw new PinyinException('CC-CEDICT dictionary data does not exist'); |
55 | 55 | } |
56 | 56 | while (($segment = array_shift($segments))) { |
57 | 57 | $this->segments[] = Arr::wrap(include $segment); |
58 | 58 | } |
59 | - $surnames = $path . '/surnames'; |
|
59 | + $surnames = $path.'/surnames'; |
|
60 | 60 | if (file_exists($surnames)) { |
61 | 61 | $this->surnames = Arr::wrap(include $surnames); |
62 | 62 | } |