for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Lit\Nimo\Traits;
use Lit\Nimo\Handlers\MiddlewareIncluedHandler;
use Lit\Nimo\Middlewares\NoopMiddleware;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
trait HandlerTrait
{
public function includeMiddleware(MiddlewareInterface $middleware): RequestHandlerInterface
/**
* @var RequestHandlerInterface $this
*/
return new MiddlewareIncluedHandler($this, $middleware);
}
public function catch(callable $catcher, string $catchClass = \Throwable::class): RequestHandlerInterface
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.
return $this->includeMiddleware(NoopMiddleware::instance()->catch($catcher, $catchClass));