Completed
Push — master ( f75002...413182 )
by Aurimas
01:24
created

SynchronousServerApplication::processRequest()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 10
rs 9.4285
nc 3
cc 2
eloc 6
nop 1
1
<?php
2
3
namespace Thruster\Component\ServerApplication;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
use Thruster\Component\Promise\ExtendedPromiseInterface;
8
use Thruster\Component\Promise\FulfilledPromise;
9
use Thruster\Component\Promise\RejectedPromise;
10
11
/**
12
 * Class SynchronousServerApplication
13
 *
14
 * @package Thruster\Component\ServerApplication
15
 * @author  Aurimas Niekis <[email protected]>
16
 */
17
abstract class SynchronousServerApplication implements ServerApplicationInterface
18
{
19
    /**
20
     * @param ServerRequestInterface $request
21
     *
22
     * @return ResponseInterface
23
     */
24
    abstract function processRequestSynchronously(ServerRequestInterface $request) : ResponseInterface;
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
26
    /**
27
     * @inheritDoc
28
     */
29
    public function processRequest(ServerRequestInterface $request) : ExtendedPromiseInterface
30
    {
31
        try {
32
            $response = $this->processRequestSynchronously($request);
33
34
            return new FulfilledPromise($response);
35
        } catch (\Throwable $e) {
36
            return new RejectedPromise($e);
37
        }
38
    }
39
}
40