GetCallByIdMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
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