Skip to content

Commit 6e1efa1

Browse files
committed
Use full namespace in function checks
1 parent f69b581 commit 6e1efa1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/StreamFactory.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,37 @@
77
use Psr\Http\Message\StreamFactoryInterface;
88
use Psr\Http\Message\StreamInterface;
99

10+
use function function_exists;
1011
use function GuzzleHttp\Psr7\stream_for;
1112
use function GuzzleHttp\Psr7\try_fopen;
1213

1314
class StreamFactory implements StreamFactoryInterface
1415
{
1516
public function createStream(string $content = ''): StreamInterface
1617
{
17-
if (\function_exists('stream_for')) {
18+
if (function_exists('GuzzleHttp\Psr7\stream_for')) {
1819
// fallback for guzzlehttp/psr7<1.7.0
1920
return stream_for($content);
2021
}
22+
2123
return Utils::streamFor($content);
2224
}
2325

2426
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
2527
{
26-
if (\function_exists('try_fopen') && \function_exists('steam_for')) {
28+
if (function_exists('GuzzleHttp\Psr7\try_fopen')) {
2729
// fallback for guzzlehttp/psr7<1.7.0
2830
$resource = try_fopen($file, $mode);
29-
30-
return stream_for($resource);
31+
} else {
32+
$resource = Utils::tryFopen($file, $mode);
3133
}
32-
$resource = Utils::tryFopen($file, $mode);
3334

34-
return new Stream($resource);
35+
36+
return $this->createStreamFromResource($resource);
3537
}
3638

3739
public function createStreamFromResource($resource): StreamInterface
3840
{
39-
if (\function_exists('stream_for')) {
40-
// fallback for guzzlehttp/psr7<1.7.0
41-
return stream_for($resource);
42-
}
4341
return new Stream($resource);
4442
}
4543
}

0 commit comments

Comments
 (0)