Total Complexity | 4 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | class Wrapper implements WrapperInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var \BitlyWrap\Adapter\Adapter |
||
18 | */ |
||
19 | private $adapter; |
||
20 | |||
21 | /** |
||
22 | * Wrapper constructor. |
||
23 | * @param Adapter $adapter |
||
24 | */ |
||
25 | 2 | public function __construct(Adapter $adapter) |
|
28 | 2 | } |
|
29 | |||
30 | /** |
||
31 | * @param string $long_url |
||
32 | * @return string |
||
33 | */ |
||
34 | 1 | public function getShortLink($long_url) |
|
35 | { |
||
36 | 1 | $adapter = $this->getAdapter(); |
|
37 | $data = [ |
||
38 | 1 | 'long_url' => $long_url |
|
39 | ]; |
||
40 | 1 | $response = $adapter->post('shorten', $data); |
|
41 | 1 | $content = $response->getBody()->getContents(); |
|
42 | 1 | $array = json_decode($content, 1); |
|
43 | 1 | return $array['link']; |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return Adapter |
||
48 | */ |
||
49 | 1 | private function getAdapter() |
|
50 | { |
||
51 | 1 | return $this->adapter; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param Adapter $adapter |
||
56 | */ |
||
57 | 2 | private function setAdapter(Adapter $adapter) |
|
60 | 2 | } |
|
61 | } |
||
62 |