Skip to content

Commit 08587b6

Browse files
Girgiasnicolas-grekas
authored andcommitted
Remove some implicit bool type juggling
1 parent 1790e23 commit 08587b6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

UnicodeString.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ public function endsWith(string|iterable|AbstractString $suffix): bool
106106
return false;
107107
}
108108

109+
$grapheme = grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)) ?: '';
110+
109111
if ($this->ignoreCase) {
110-
return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8');
112+
return 0 === mb_stripos($grapheme, $suffix, 0, 'UTF-8');
111113
}
112114

113-
return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
115+
return $suffix === $grapheme;
114116
}
115117

116118
public function equalsTo(string|iterable|AbstractString $string): bool
@@ -355,11 +357,13 @@ public function startsWith(string|iterable|AbstractString $prefix): bool
355357
return false;
356358
}
357359

360+
$grapheme = grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES) ?: '';
361+
358362
if ($this->ignoreCase) {
359-
return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8');
363+
return 0 === mb_stripos($grapheme, $prefix, 0, 'UTF-8');
360364
}
361365

362-
return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES);
366+
return $prefix === $grapheme;
363367
}
364368

365369
public function __wakeup(): void

0 commit comments

Comments
 (0)