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
 * @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