@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | class Pinyin |
18 | 18 | { |
19 | 19 | private const SEGMENTS_COUNT = 10; |
20 | - private const WORDS_PATH = __DIR__.'/../data/words-%s.php'; |
|
21 | - private const SURNAMES_PATH = __DIR__.'/../data/surnames.php'; |
|
20 | + private const WORDS_PATH = __DIR__ . '/../data/words-%s.php'; |
|
21 | + private const SURNAMES_PATH = __DIR__ . '/../data/surnames.php'; |
|
22 | 22 | |
23 | 23 | protected array $punctuations = [ |
24 | 24 | ',' => ',', |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | return implode($delimiter, $this->convert($string, $option | \PINYIN_KEEP_NUMBER | \PINYIN_KEEP_ENGLISH)); |
70 | 70 | } |
71 | 71 | |
72 | - public function abbr(string $string, int|string $delimiter = '', int $option = null): string |
|
72 | + public function abbr(string $string, int | string $delimiter = '', int $option = null): string |
|
73 | 73 | { |
74 | 74 | $option = $option ?? $this->defaultOptions; |
75 | 75 | |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | $result = $this->convert($string, $option | \PINYIN_NO_TONE); |
85 | 85 | } |
86 | 86 | |
87 | - return implode($delimiter, array_map(function ($pinyin) { |
|
87 | + return implode($delimiter, array_map(function($pinyin) { |
|
88 | 88 | return \is_numeric($pinyin) || preg_match('/\d+/', $pinyin) ? $pinyin : \mb_substr($pinyin, 0, 1); |
89 | 89 | }, $result)); |
90 | 90 | } |
91 | 91 | |
92 | - public function phrase(string $string, string|int $delimiter = ' ', int|string $option = null): string |
|
92 | + public function phrase(string $string, string | int $delimiter = ' ', int | string $option = null): string |
|
93 | 93 | { |
94 | 94 | $option = $option ?? $this->defaultOptions; |
95 | 95 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return implode($delimiter, $this->convert($string, $option)); |
101 | 101 | } |
102 | 102 | |
103 | - public function sentence(string $string, string|int $delimiter = ' ', int|string $option = null): string |
|
103 | + public function sentence(string $string, string | int $delimiter = ' ', int | string $option = null): string |
|
104 | 104 | { |
105 | 105 | $option = $option ?? $this->defaultOptions; |
106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | protected function prepare(string $string, int $option): string |
162 | 162 | { |
163 | - $string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) { |
|
163 | + $string = preg_replace_callback('~[a-z0-9_-]+~i', function($matches) { |
|
164 | 164 | return "\t" . $matches[0]; |
165 | 165 | }, $string); |
166 | 166 |