Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
All exceptions inherit RuntimeException
Browse files Browse the repository at this point in the history
  • Loading branch information
fenric committed Nov 18, 2018
1 parent 7e652c5 commit effb7e2
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 58 deletions.
23 changes: 0 additions & 23 deletions src/Exception/Exception.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/Exception/InvalidArgumentException.php

This file was deleted.

7 changes: 6 additions & 1 deletion src/Exception/UnopenableStreamException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

namespace Sunrise\Stream\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UnopenableStreamException
*/
class UnopenableStreamException extends Exception
class UnopenableStreamException extends RuntimeException
{}
7 changes: 6 additions & 1 deletion src/Exception/UnreadableStreamException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

namespace Sunrise\Stream\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UnreadableStreamException
*/
class UnreadableStreamException extends Exception
class UnreadableStreamException extends RuntimeException
{}
7 changes: 6 additions & 1 deletion src/Exception/UnseekableStreamException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

namespace Sunrise\Stream\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UnseekableStreamException
*/
class UnseekableStreamException extends Exception
class UnseekableStreamException extends RuntimeException
{}
7 changes: 6 additions & 1 deletion src/Exception/UntellableStreamException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

namespace Sunrise\Stream\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UntellableStreamException
*/
class UntellableStreamException extends Exception
class UntellableStreamException extends RuntimeException
{}
7 changes: 6 additions & 1 deletion src/Exception/UnwritableStreamException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

namespace Sunrise\Stream\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UnwritableStreamException
*/
class UnwritableStreamException extends Exception
class UnwritableStreamException extends RuntimeException
{}
4 changes: 2 additions & 2 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class Stream implements StreamInterface
*
* @param resource $resource
*
* @throws Exception\InvalidArgumentException
* @throws \InvalidArgumentException
*/
public function __construct($resource)
{
if (! \is_resource($resource))
{
throw new Exception\InvalidArgumentException('Invalid stream resource');
throw new \InvalidArgumentException('Invalid stream resource');
}

$this->resource = $resource;
Expand Down
16 changes: 6 additions & 10 deletions tests/StreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use PHPUnit\Framework\TestCase;
use Psr\Http\Message\StreamInterface;
use Sunrise\Stream\Exception\Exception;
use Sunrise\Stream\Exception\InvalidArgumentException;
use Sunrise\Stream\Exception\UnopenableStreamException;
use Sunrise\Stream\Exception\UnreadableStreamException;
use Sunrise\Stream\Exception\UnseekableStreamException;
Expand Down Expand Up @@ -261,7 +259,7 @@ public function testToString()

public function testConstructorWithInvalidResource()
{
$this->expectException(InvalidArgumentException::class);
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid stream resource');

new Stream('');
Expand Down Expand Up @@ -402,13 +400,11 @@ public function testToStringUnreadable()

public function testExceptions()
{
$this->assertInstanceOf(\RuntimeException::class, new Exception(''));
$this->assertInstanceOf(Exception::class, new InvalidArgumentException(''));
$this->assertInstanceOf(Exception::class, new UnopenableStreamException(''));
$this->assertInstanceOf(Exception::class, new UnreadableStreamException(''));
$this->assertInstanceOf(Exception::class, new UnseekableStreamException(''));
$this->assertInstanceOf(Exception::class, new UntellableStreamException(''));
$this->assertInstanceOf(Exception::class, new UnwritableStreamException(''));
$this->assertInstanceOf(\RuntimeException::class, new UnopenableStreamException(''));
$this->assertInstanceOf(\RuntimeException::class, new UnreadableStreamException(''));
$this->assertInstanceOf(\RuntimeException::class, new UnseekableStreamException(''));
$this->assertInstanceOf(\RuntimeException::class, new UntellableStreamException(''));
$this->assertInstanceOf(\RuntimeException::class, new UnwritableStreamException(''));
}

private function assertStreamResourceEquals(StreamInterface $stream, $expected)
Expand Down

0 comments on commit effb7e2

Please sign in to comment.