Skip to content

Commit 8267902

Browse files
committed
Improve Stream handling
1 parent 1262646 commit 8267902

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Stream.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ final class Stream
2222
*/
2323
public static function getContentAsString(string $path, $context = null): string
2424
{
25-
$resource = self::getResource($path, $context);
26-
if (false === $resource) {
25+
$stream = self::fromPath($path, $context);
26+
if (false === $stream) {
2727
throw UnableToLoadResource::dueToInvalidUri($path);
2828
}
2929

3030
/** @var string $content */
31-
$content = stream_get_contents($resource);
32-
fclose($resource);
31+
$content = stream_get_contents($stream);
32+
fclose($stream);
3333

3434
return $content;
3535
}
@@ -39,7 +39,7 @@ public static function getContentAsString(string $path, $context = null): string
3939
*
4040
* @return false|resource
4141
*/
42-
private static function getResource(string $path, $context = null)
42+
private static function fromPath(string $path, $context = null)
4343
{
4444
if (null === $context) {
4545
return @fopen($path, 'r');

src/UnableToLoadResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Pdp;
66

7-
use InvalidArgumentException;
7+
use RuntimeException;
88
use Throwable;
99

10-
final class UnableToLoadResource extends InvalidArgumentException implements CannotProcessHost
10+
final class UnableToLoadResource extends RuntimeException implements CannotProcessHost
1111
{
1212
public static function dueToInvalidUri(string $uri): self
1313
{

0 commit comments

Comments
 (0)