-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from sasezaki/return-type-clear
Introduce DispatchResult - Dispatcher must not have Response itself
- Loading branch information
Showing
7 changed files
with
95 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Backbeard; | ||
|
||
use Psr\Http\Message\ResponseInterface as Response; | ||
use LogicException; | ||
|
||
class DispatchResult implements DispatchResultInterface | ||
{ | ||
private $dispatched; | ||
private $response; | ||
|
||
public function __construct($dispatched, $response = null) | ||
{ | ||
$this->dispatched = $dispatched; | ||
$this->response = $response; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isDispatched() | ||
{ | ||
return $this->dispatched; | ||
} | ||
|
||
/** | ||
* @return Response; | ||
*/ | ||
public function getResponse() | ||
{ | ||
if ($this->response instanceof Response) { | ||
return $this->response; | ||
} | ||
throw new LogicException("Don't call when dispatch return false"); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace Backbeard; | ||
|
||
interface DispatchResultInterface | ||
{ | ||
/** | ||
* @return bool | ||
*/ | ||
public function isDispatched(); | ||
|
||
/** | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function getResponse(); | ||
} |
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
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