GetCallByIdMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 6 1
A __construct() 0 3 1
1
<?php
2
3
namespace Phrlog\Zvonok\Phone\Mapper;
4
5
use JsonMapper;
6
use Phrlog\Zvonok\Phone\Response\CallResultResponse;
7
use Phrlog\Zvonok\Phone\Response\ResponseInterface;
8
9
/**
10
 * Class GetCallByIdMapper
11
 */
12
class GetCallByIdMapper implements ResponseInterface
13
{
14
    /**
15
     * @var JsonMapper
16
     */
17
    protected $mapper;
18
19
    /**
20
     * CallByIdMapper constructor.
21
     * @param JsonMapper $mapper
22
     */
23
    public function __construct(JsonMapper $mapper)
24
    {
25
        $this->mapper = $mapper;
26
    }
27
28
    /**
29
     * @see https://zvonok.com/pages/ru/guide/guide_api/#call_by_id
30
     *
31
     * @param string $json
32
     *
33
     * @return CallResultResponse
34
     * @throws \JsonMapper_Exception
35
     */
36
    public function map(string $json): CallResultResponse
37
    {
38
        // calltools.ru свой ответ оборачивают в массив
39
        $json = json_decode($json)[0];
40
41
        return $this->mapper->map($json, new CallResultResponse());
42
    }
43
}
44