Skip to content

Commit 304c29d

Browse files
committed
Leverage str_starts_with(), str_ends_with() and str_contains()
1 parent e6f132c commit 304c29d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Crawler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function addHtmlContent(string $content, string $charset = 'UTF-8')
215215
public function addXmlContent(string $content, string $charset = 'UTF-8', int $options = \LIBXML_NONET)
216216
{
217217
// remove the default namespace if it's the only namespace to make XPath expressions simpler
218-
if (!preg_match('/xmlns:/', $content)) {
218+
if (!str_contains($content, 'xmlns:')) {
219219
$content = str_replace('xmlns', 'ns', $content);
220220
}
221221

UriResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function resolve(string $uri, ?string $baseUri): string
5858
}
5959

6060
// absolute URL with relative schema
61-
if (0 === strpos($uri, '//')) {
61+
if (str_starts_with($uri, '//')) {
6262
return preg_replace('#^([^/]*)//.*$#', '$1', $baseUriCleaned).$uri;
6363
}
6464

@@ -85,7 +85,7 @@ private static function canonicalizePath(string $path): string
8585
return $path;
8686
}
8787

88-
if ('.' === substr($path, -1)) {
88+
if (str_ends_with($path, '.')) {
8989
$path .= '/';
9090
}
9191

0 commit comments

Comments
 (0)