Skip to content

Commit 4f637ec

Browse files
committed
Use str_contains where applicable
1 parent 388acd9 commit 4f637ec

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/Provider/AbstractProvider.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
use function parse_str;
5555
use function random_bytes;
5656
use function sprintf;
57-
use function strpos;
58-
use function strstr;
57+
use function str_contains;
5958
use function strtr;
6059
use function substr;
6160
use function trim;
@@ -514,7 +513,7 @@ protected function appendQuery(string $url, string $query): string
514513
$query = trim($query, '?&');
515514

516515
if ($query) {
517-
$glue = strstr($url, '?') === false ? '?' : '&';
516+
$glue = !str_contains($url, '?') ? '?' : '&';
518517

519518
return $url . $glue . $query;
520519
}
@@ -828,7 +827,7 @@ protected function parseResponse(ResponseInterface $response): array | string
828827
$content = (string) $response->getBody();
829828
$type = $this->getContentType($response);
830829

831-
if (strpos($type, 'urlencoded') !== false) {
830+
if (str_contains($type, 'urlencoded')) {
832831
parse_str($content, $parsed);
833832

834833
/** @var array<string, string> */
@@ -841,7 +840,7 @@ protected function parseResponse(ResponseInterface $response): array | string
841840
try {
842841
return $this->parseJson($content);
843842
} catch (UnexpectedValueException $e) {
844-
if (strpos($type, 'json') !== false) {
843+
if (str_contains($type, 'json')) {
845844
throw $e;
846845
}
847846

src/Tool/ArrayAccessorTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use function explode;
2323
use function is_array;
2424
use function is_string;
25-
use function strpos;
25+
use function str_contains;
2626

2727
/**
2828
* Provides generic array navigation tools.
@@ -40,7 +40,7 @@ private function getValueByKey(array $data, mixed $key, mixed $default = null):
4040
return $default;
4141
}
4242

43-
if (strpos($key, '.') !== false) {
43+
if (str_contains($key, '.')) {
4444
$keys = explode('.', $key);
4545

4646
foreach ($keys as $innerKey) {

test/src/Provider/AbstractProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
use function parse_str;
4040
use function parse_url;
4141
use function preg_match;
42-
use function strpos;
42+
use function str_contains;
4343
use function time;
4444
use function uniqid;
4545

@@ -124,7 +124,7 @@ public function testAuthorizationUrlStateParam(): void
124124
'state' => 'XXX',
125125
]);
126126

127-
$this->assertTrue(strpos($authUrl, 'state=XXX') !== false);
127+
$this->assertTrue(str_contains($authUrl, 'state=XXX'));
128128
}
129129

130130
/**

0 commit comments

Comments
 (0)