This repository has been archived by the owner on Sep 14, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced the quirky exception system with a collection of multiple
exceptions that represent the error state.
- Loading branch information
1 parent
3ca18b5
commit e320c5a
Showing
9 changed files
with
96 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Groundhog\Router; | ||
|
||
/** | ||
* This exception represents an error where a route | ||
* exists, but the requested method is not allowed. | ||
* It will usually provide a set of allowed methods. | ||
*/ | ||
class ExceptionMethodNotAllowed extends \Exception | ||
{ | ||
/** | ||
* The methods that would be allowed | ||
* | ||
* @var array | ||
*/ | ||
protected $allowed_methods; | ||
|
||
/** | ||
* Adds a context array to the standard exception | ||
* | ||
* @param string[] $allowed_methods The set of methods that would be allowed | ||
* @param string $message | ||
* @param integer $code | ||
* @param \Exception $previous | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(array $allowed_methods = array(), $message = '', $code = 0, \Exception $previous = null) | ||
{ | ||
parent::__construct($message, $code, $previous); | ||
|
||
$this->allowed_methods = $allowed_methods; | ||
} | ||
|
||
/** | ||
* Get the methods that would be allowed | ||
* | ||
* @return array | ||
*/ | ||
public function getAllowedMethods() | ||
{ | ||
return $this->allowed_methods; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Groundhog\Router; | ||
|
||
/** | ||
* This exception represents the error condition where | ||
* a requested route is not found. | ||
*/ | ||
class ExceptionNotFound extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/Groundhog/Router/Tests/ExceptionMethodNotAllowedTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Groundhog\Router\Tests; | ||
|
||
use Groundhog\Router\ExceptionMethodNotAllowed; | ||
|
||
class ExceptionMethodNotAllowedTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testgetAllowedMethods() | ||
{ | ||
$exception = new ExceptionMethodNotAllowed( | ||
array('context' => 'array') | ||
); | ||
|
||
$this->assertSame( array('context' => 'array'), $exception->getAllowedMethods()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.