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

SynchronousServerApplication   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
processRequestSynchronously() 0 1 ?
A processRequest() 0 10 2
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