diff --git a/src/FileDictLoader.php b/src/FileDictLoader.php index 82491105..717088d8 100644 --- a/src/FileDictLoader.php +++ b/src/FileDictLoader.php @@ -47,7 +47,7 @@ public function __construct($path) public function map(Closure $callback) { for ($i = 0; $i < 100; ++$i) { - $segment = $this->path.'/'.sprintf($this->segmentName, $i); + $segment = $this->path . '/' . sprintf($this->segmentName, $i); if (file_exists($segment)) { $dictionary = (array) include $segment; @@ -63,7 +63,7 @@ public function map(Closure $callback) */ public function mapSurname(Closure $callback) { - $surnames = $this->path.'/surnames'; + $surnames = $this->path . '/surnames'; if (file_exists($surnames)) { $dictionary = (array) include $surnames; diff --git a/src/GeneratorFileDictLoader.php b/src/GeneratorFileDictLoader.php index 96183cba..ef8900b2 100644 --- a/src/GeneratorFileDictLoader.php +++ b/src/GeneratorFileDictLoader.php @@ -55,7 +55,7 @@ public function __construct($path) $this->path = $path; for ($i = 0; $i < 100; ++$i) { - $segment = $this->path.'/'.sprintf($this->segmentName, $i); + $segment = $this->path . '/' . sprintf($this->segmentName, $i); if (file_exists($segment) && is_file($segment)) { array_push(static::$handles, $this->openFile($segment)); @@ -134,7 +134,7 @@ public function map(Closure $callback) public function mapSurname(Closure $callback) { if (!static::$surnamesHandle instanceof SplFileObject) { - static::$surnamesHandle = $this->openFile($this->path.'/surnames'); + static::$surnamesHandle = $this->openFile($this->path . '/surnames'); } $this->traversing($this->getGenerator([static::$surnamesHandle]), $callback); diff --git a/src/MemoryFileDictLoader.php b/src/MemoryFileDictLoader.php index 834f756e..7a9ae5e7 100644 --- a/src/MemoryFileDictLoader.php +++ b/src/MemoryFileDictLoader.php @@ -53,7 +53,7 @@ public function __construct($path) $this->path = $path; for ($i = 0; $i < 100; ++$i) { - $segment = $path.'/'.sprintf($this->segmentName, $i); + $segment = $path . '/' . sprintf($this->segmentName, $i); if (file_exists($segment)) { $this->segments[] = (array) include $segment; @@ -81,7 +81,7 @@ public function map(Closure $callback) public function mapSurname(Closure $callback) { if (empty($this->surnames)) { - $surnames = $this->path.'/surnames'; + $surnames = $this->path . '/surnames'; if (file_exists($surnames)) { $this->surnames = (array) include $surnames; diff --git a/src/Pinyin.php b/src/Pinyin.php index 97d9fb6f..0f70b8c3 100644 --- a/src/Pinyin.php +++ b/src/Pinyin.php @@ -182,7 +182,7 @@ public function setLoader(DictLoaderInterface $loader) public function getLoader() { if (!($this->loader instanceof DictLoaderInterface)) { - $dataDir = dirname(__DIR__).'/data/'; + $dataDir = dirname(__DIR__) . '/data/'; $loaderName = $this->loader; $this->loader = new $loaderName($dataDir); @@ -229,7 +229,7 @@ protected function convertSurname($string, $dictLoader) $dictLoader->mapSurname(function ($dictionary) use (&$string) { foreach ($dictionary as $surname => $pinyin) { if (0 === strpos($string, $surname)) { - $string = $pinyin.mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); + $string = $pinyin . mb_substr($string, mb_strlen($surname, 'UTF-8'), mb_strlen($string, 'UTF-8') - 1, 'UTF-8'); break; } @@ -282,7 +282,7 @@ public function hasOption($option, $check) protected function prepare($string, $option = \PINYIN_DEFAULT) { $string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) { - return "\t".$matches[0]; + return "\t" . $matches[0]; }, $string); $regex = ['\p{Han}', '\p{Z}', '\p{M}', "\t"]; @@ -332,7 +332,7 @@ protected function formatTone($pinyin, $option = \PINYIN_NO_TONE) $umlaut = 'v'; } - $pinyin = str_replace($unicode, $umlaut, $pinyin).($this->hasOption($option, PINYIN_ASCII_TONE) ? $replacement[1] : ''); + $pinyin = str_replace($unicode, $umlaut, $pinyin) . ($this->hasOption($option, PINYIN_ASCII_TONE) ? $replacement[1] : ''); } }