Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit d0debca

Browse files
committed
Refactored ReachedFinalHandlerException to use named constructor
1 parent cebe041 commit d0debca

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

src/Exception/ReachedFinalHandlerException.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@
1111

1212
class ReachedFinalHandlerException extends RuntimeException
1313
{
14+
/**
15+
* @return self
16+
*/
17+
public static function create()
18+
{
19+
return new self('Reached the final handler for middleware pipe - check the pipe configuration');
20+
}
1421
}

src/MiddlewareListener.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ public function onDispatch(MvcEvent $event)
8484
$psr7Request,
8585
$psr7ResponsePrototype,
8686
function (PsrServerRequestInterface $request, PsrResponseInterface $response) {
87-
throw new ReachedFinalHandlerException(
88-
'Reached the final handler for middleware pipe - check the pipe configuration'
89-
);
87+
throw ReachedFinalHandlerException::create();
9088
}
9189
);
9290
} catch (\Throwable $ex) {

test/Exception/MiddlewareNotCallableExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Zend Framework (http://framework.zend.com/)
44
*
55
* @link http://github.com/zendframework/zf2 for the canonical source repository
6-
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
6+
* @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com)
77
* @license http://framework.zend.com/license/new-bsd New BSD License
88
*/
99

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Zend Framework (http://framework.zend.com/)
4+
*
5+
* @link http://github.com/zendframework/zf2 for the canonical source repository
6+
* @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com)
7+
* @license http://framework.zend.com/license/new-bsd New BSD License
8+
*/
9+
10+
namespace ZendTest\Mvc;
11+
12+
use PHPUnit_Framework_TestCase as TestCase;
13+
use Zend\Mvc\Exception\ReachedFinalHandlerException;
14+
15+
final class ReachedFinalHandlerExceptionTest extends TestCase
16+
{
17+
public function testFromNothing()
18+
{
19+
$exception = ReachedFinalHandlerException::create();
20+
21+
$this->assertInstanceOf(ReachedFinalHandlerException::class, $exception);
22+
$this->assertSame(
23+
'Reached the final handler for middleware pipe - check the pipe configuration',
24+
$exception->getMessage()
25+
);
26+
}
27+
}

0 commit comments

Comments
 (0)