Responder::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Decorator Implementation
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\Contract\Patterns\Implementation\Decorator;
11
12
use Ticaje\Contract\Patterns\Interfaces\Decorator\Responder\ResponseInterface;
13
use Ticaje\Contract\Patterns\Interfaces\Decorator\ResponderInterface;
14
15
/**
16
 * Class Responder
17
 * @package Ticaje\Contract\Patterns\Implementation\Decorator
18
 * @todo Document overview of this module
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])
0 ignored issues
show
Bug introduced by
The method setSuccess() does not exist on Ticaje\Contract\Patterns...onder\ResponseInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Ticaje\Contract\Patterns...onder\ResponseInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
            ->/** @scrutinizer ignore-call */ 
41
              setSuccess($response[self::SUCCESS_KEY])
Loading history...
41
            ->setContent(json_decode(json_encode($response[self::CONTENT_KEY])))
42
            ->setMessage($response[self::MESSAGE_KEY]);
43
        return $this->response;
44
    }
45
}
46