Skip to content

Commit be70287

Browse files
committed
Leverage str_starts_with(), str_ends_with() and str_contains()
1 parent 9a805f1 commit be70287

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

AbstractBrowser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public function restart()
604604
protected function getAbsoluteUri(string $uri): string
605605
{
606606
// already absolute?
607-
if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) {
607+
if (str_starts_with($uri, 'http://') || str_starts_with($uri, 'https://')) {
608608
return $uri;
609609
}
610610

@@ -618,7 +618,7 @@ protected function getAbsoluteUri(string $uri): string
618618
}
619619

620620
// protocol relative URL
621-
if (0 === strpos($uri, '//')) {
621+
if (str_starts_with($uri, '//')) {
622622
return parse_url($currentUri, \PHP_URL_SCHEME).':'.$uri;
623623
}
624624

@@ -630,7 +630,7 @@ protected function getAbsoluteUri(string $uri): string
630630
if ('/' !== $uri[0]) {
631631
$path = parse_url($currentUri, \PHP_URL_PATH);
632632

633-
if ('/' !== substr($path, -1)) {
633+
if (!str_ends_with($path, '/')) {
634634
$path = substr($path, 0, strrpos($path, '/') + 1);
635635
}
636636

CookieJar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@ public function allValues(string $uri, bool $returnsRawValue = false): array
169169
foreach ($this->cookieJar as $domain => $pathCookies) {
170170
if ($domain) {
171171
$domain = '.'.ltrim($domain, '.');
172-
if ($domain != substr('.'.$parts['host'], -\strlen($domain))) {
172+
if (!str_ends_with('.'.$parts['host'], $domain)) {
173173
continue;
174174
}
175175
}
176176

177177
foreach ($pathCookies as $path => $namedCookies) {
178-
if ($path != substr($parts['path'], 0, \strlen($path))) {
178+
if (!str_starts_with($parts['path'], $path)) {
179179
continue;
180180
}
181181

0 commit comments

Comments
 (0)