Responder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 7 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Decorator Implementation
6
 * @category    Ticaje
7
 * @package     Ticaje_Contract
8
 * @author      Hector Luis Barrientos <[email protected]>
9
 */
10
11
namespace Ticaje\Contract\Patterns\Implementation\Decorator;
12
13
use Ticaje\Contract\Patterns\Interfaces\Decorator\Responder\ResponseInterface;
14
use Ticaje\Contract\Patterns\Interfaces\Decorator\ResponderInterface;
15
16
/**
17
 * Class Responder
18
 * @package Ticaje\Contract\Patterns\Implementation\Decorator
19
 */
20
class Responder implements ResponderInterface
21
{
22
    private $response;
23
24
    /**
25
     * Responder constructor.
26
     * @param ResponseInterface $response
27
     */
28
    public function __construct(
29
        ResponseInterface $response
30
    ) {
31
        $this->response = $response;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    public function process(array $response): ResponseInterface
38
    {
39
        $this->response
40
            ->setSuccess($response[self::SUCCESS_KEY])
41
            ->setContent(json_decode(json_encode($response[self::CONTENT_KEY])))
42
            ->setMessage($response[self::MESSAGE_KEY]);
43
        return $this->response;
44
    }
45
}
46