| @@ -7,13 +7,13 @@ | ||
| 7 | 7 | * |
| 8 | 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | 9 | * file that was distributed with this source code. |
| 10 | 10 | */ |
| 11 | -namespace WindPressPackages\Symfony\Component\String; | |
| 11 | +namespace WindPressDeps\Symfony\Component\String; | |
| 12 | 12 | |
| 13 | -use WindPressPackages\Symfony\Component\String\Exception\ExceptionInterface; | |
| 14 | -use WindPressPackages\Symfony\Component\String\Exception\InvalidArgumentException; | |
| 15 | -use WindPressPackages\Symfony\Component\String\Exception\RuntimeException; | |
| 13 | +use WindPressDeps\Symfony\Component\String\Exception\ExceptionInterface; | |
| 14 | +use WindPressDeps\Symfony\Component\String\Exception\InvalidArgumentException; | |
| 15 | +use WindPressDeps\Symfony\Component\String\Exception\RuntimeException; | |
| 16 | 16 | /** |
| 17 | 17 | * Represents a binary-safe string of bytes. |
| 18 | 18 | * |
| 19 | 19 | * @author Nicolas Grekas <p@tchwork.com> |
| @@ -77,14 +77,14 @@ | ||
| 77 | 77 | } |
| 78 | 78 | public function bytesAt(int $offset): array |
| 79 | 79 | { |
| 80 | 80 | $str = $this->string[$offset] ?? ''; |
| 81 | - return ('' === $str) ? [] : [\ord($str)]; | |
| 81 | + return '' === $str ? [] : [\ord($str)]; | |
| 82 | 82 | } |
| 83 | 83 | public function append(string ...$suffix): parent |
| 84 | 84 | { |
| 85 | 85 | $str = clone $this; |
| 86 | - $str->string .= (1 >= \count($suffix)) ? $suffix[0] ?? '' : implode('', $suffix); | |
| 86 | + $str->string .= 1 >= \count($suffix) ? $suffix[0] ?? '' : implode('', $suffix); | |
| 87 | 87 | return $str; |
| 88 | 88 | } |
| 89 | 89 | public function camel(): parent |
| 90 | 90 | { |
| @@ -89,9 +89,9 @@ | ||
| 89 | 89 | public function camel(): parent |
| 90 | 90 | { |
| 91 | 91 | $str = clone $this; |
| 92 | 92 | $parts = explode(' ', trim(ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string)))); |
| 93 | - $parts[0] = (1 !== \strlen($parts[0]) && ctype_upper($parts[0])) ? $parts[0] : lcfirst($parts[0]); | |
| 93 | + $parts[0] = 1 !== \strlen($parts[0]) && ctype_upper($parts[0]) ? $parts[0] : lcfirst($parts[0]); | |
| 94 | 94 | $str->string = implode('', $parts); |
| 95 | 95 | return $str; |
| 96 | 96 | } |
| 97 | 97 | public function chunk(int $length = 1): array |
| @@ -153,9 +153,9 @@ | ||
| 153 | 153 | if ('' === $needle) { |
| 154 | 154 | return null; |
| 155 | 155 | } |
| 156 | 156 | $i = $this->ignoreCase ? stripos($this->string, $needle, $offset) : strpos($this->string, $needle, $offset); |
| 157 | - return (\false === $i) ? null : $i; | |
| 157 | + return \false === $i ? null : $i; | |
| 158 | 158 | } |
| 159 | 159 | public function indexOfLast($needle, int $offset = 0): ?int |
| 160 | 160 | { |
| 161 | 161 | if ($needle instanceof parent) { |
| @@ -168,9 +168,9 @@ | ||
| 168 | 168 | if ('' === $needle) { |
| 169 | 169 | return null; |
| 170 | 170 | } |
| 171 | 171 | $i = $this->ignoreCase ? strripos($this->string, $needle, $offset) : strrpos($this->string, $needle, $offset); |
| 172 | - return (\false === $i) ? null : $i; | |
| 172 | + return \false === $i ? null : $i; | |
| 173 | 173 | } |
| 174 | 174 | public function isUtf8(): bool |
| 175 | 175 | { |
| 176 | 176 | return '' === $this->string || preg_match('//u', $this->string); |
| @@ -177,9 +177,9 @@ | ||
| 177 | 177 | } |
| 178 | 178 | public function join(array $strings, ?string $lastGlue = null): parent |
| 179 | 179 | { |
| 180 | 180 | $str = clone $this; |
| 181 | - $tail = (null !== $lastGlue && 1 < \count($strings)) ? $lastGlue . array_pop($strings) : ''; | |
| 181 | + $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue . array_pop($strings) : ''; | |
| 182 | 182 | $str->string = implode($this->string, $strings) . $tail; |
| 183 | 183 | return $str; |
| 184 | 184 | } |
| 185 | 185 | public function length(): int |
| @@ -193,9 +193,9 @@ | ||
| 193 | 193 | return $str; |
| 194 | 194 | } |
| 195 | 195 | public function match(string $regexp, int $flags = 0, int $offset = 0): array |
| 196 | 196 | { |
| 197 | - $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match'; | |
| 197 | + $match = (\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags ? 'preg_match_all' : 'preg_match'; | |
| 198 | 198 | if ($this->ignoreCase) { |
| 199 | 199 | $regexp .= 'i'; |
| 200 | 200 | } |
| 201 | 201 | set_error_handler(static function ($t, $m) { |
| @@ -236,9 +236,9 @@ | ||
| 236 | 236 | } |
| 237 | 237 | public function prepend(string ...$prefix): parent |
| 238 | 238 | { |
| 239 | 239 | $str = clone $this; |
| 240 | - $str->string = ((1 >= \count($prefix)) ? $prefix[0] ?? '' : implode('', $prefix)) . $str->string; | |
| 240 | + $str->string = (1 >= \count($prefix) ? $prefix[0] ?? '' : implode('', $prefix)) . $str->string; | |
| 241 | 241 | return $str; |
| 242 | 242 | } |
| 243 | 243 | public function replace(string $from, string $to): parent |
| 244 | 244 | { |
| @@ -258,9 +258,9 @@ | ||
| 258 | 258 | throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class)); |
| 259 | 259 | } |
| 260 | 260 | $replace = 'preg_replace_callback'; |
| 261 | 261 | } else { |
| 262 | - $replace = ($to instanceof \Closure) ? 'preg_replace_callback' : 'preg_replace'; | |
| 262 | + $replace = $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace'; | |
| 263 | 263 | } |
| 264 | 264 | set_error_handler(static function ($t, $m) { |
| 265 | 265 | throw new InvalidArgumentException($m); |
| 266 | 266 | }); |
| @@ -356,9 +356,9 @@ | ||
| 356 | 356 | try { |
| 357 | 357 | try { |
| 358 | 358 | $validEncoding = \false !== mb_detect_encoding($this->string, $fromEncoding ?? 'Windows-1252', \true); |
| 359 | 359 | } catch (InvalidArgumentException $e) { |
| 360 | - if (!\function_exists('iconv') && !\function_exists('WindPressPackages\iconv')) { | |
| 360 | + if (!\function_exists('iconv') && !\function_exists('WindPressDeps\iconv')) { | |
| 361 | 361 | throw $e; |
| 362 | 362 | } |
| 363 | 363 | $u->string = iconv($fromEncoding ?? 'Windows-1252', 'UTF-8', $this->string); |
| 364 | 364 | return $u; |