Passed
Push — master ( f810f8...50b794 )
by Rougin
01:59
created

MessageProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 3
1
<?php
2
3
namespace Zapheus\Bridge\Psr;
4
5
use Zapheus\Container\WritableInterface;
6
use Zapheus\Provider\ProviderInterface;
7
8
/**
9
 * Message Provider
10
 *
11
 * @package Zapheus
12
 * @author  Rougin Royce Gutib <[email protected]>
13
 */
14
class MessageProvider implements ProviderInterface
15
{
16
    const PSR_REQUEST = 'Psr\Http\Message\ServerRequestInterface';
17
18
    const PSR_RESPONSE = 'Psr\Http\Message\ResponseInterface';
19
20
    const ZAPHEUS_REQUEST = 'Zapheus\Http\Message\RequestInterface';
21
22
    const ZAPHEUS_RESPONSE = 'Zapheus\Http\Message\ResponseInterface';
23
24
    /**
25
     * Registers the bindings in the container.
26
     *
27
     * @param  \Zapheus\Container\WritableInterface $container
28
     * @return \Zapheus\Container\ContainerInterface
29
     */
30 3
    public function register(WritableInterface $container)
31
    {
32 3
        if ($container->has(self::ZAPHEUS_REQUEST)) {
33 3
            $request = $container->get(self::ZAPHEUS_REQUEST);
34
35 3
            $request = new Interop\ServerRequest($request);
36
37 3
            $container->set(self::PSR_REQUEST, $request);
38 2
        }
39
40 3
        if ($container->has(self::ZAPHEUS_RESPONSE)) {
41 3
            $response = $container->get(self::ZAPHEUS_RESPONSE);
42
43 3
            $response = new Interop\Response($response);
44
45 3
            $container->set(self::PSR_RESPONSE, $response);
46 2
        }
47
48 3
        return $container;
49
    }
50
}
51