@@ -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 | public function __construct(protected int $defaultOptions = \PINYIN_DEFAULT) |
24 | 24 | { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | return implode($delimiter, $this->convert($string, $option | \PINYIN_KEEP_NUMBER | \PINYIN_KEEP_ENGLISH)); |
57 | 57 | } |
58 | 58 | |
59 | - public function abbr(string $string, int|string $delimiter = '', int $option = null): string |
|
59 | + public function abbr(string $string, int | string $delimiter = '', int $option = null): string |
|
60 | 60 | { |
61 | 61 | $option = $option ?? $this->defaultOptions; |
62 | 62 | |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | $result = $this->convert($string, $option | \PINYIN_NO_TONE); |
72 | 72 | } |
73 | 73 | |
74 | - return implode($delimiter, array_map(function ($pinyin) { |
|
74 | + return implode($delimiter, array_map(function($pinyin) { |
|
75 | 75 | return \is_numeric($pinyin) || preg_match('/\d+/', $pinyin) ? $pinyin : \mb_substr($pinyin, 0, 1); |
76 | 76 | }, $result)); |
77 | 77 | } |
78 | 78 | |
79 | - public function phrase(string $string, string|int $delimiter = ' ', int|string $option = null): string |
|
79 | + public function phrase(string $string, string | int $delimiter = ' ', int | string $option = null): string |
|
80 | 80 | { |
81 | 81 | $option = $option ?? $this->defaultOptions; |
82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | return implode($delimiter, $this->convert($string, $option)); |
88 | 88 | } |
89 | 89 | |
90 | - public function sentence(string $string, string|int $delimiter = ' ', int|string $option = null): string |
|
90 | + public function sentence(string $string, string | int $delimiter = ' ', int | string $option = null): string |
|
91 | 91 | { |
92 | 92 | $option = $option ?? $this->defaultOptions; |
93 | 93 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | protected function prepare(string $string, int $option): string |
151 | 151 | { |
152 | - $string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) { |
|
152 | + $string = preg_replace_callback('~[a-z0-9_-]+~i', function($matches) { |
|
153 | 153 | return "\t" . $matches[0]; |
154 | 154 | }, $string); |
155 | 155 |