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