1 | <?php |
||
16 | class Bitly extends DriversAbstract implements DriverInterface |
||
17 | { |
||
18 | use ValidatorTrait; |
||
19 | |||
20 | /** |
||
21 | * the response data format. |
||
22 | */ |
||
23 | const RESPONSE_FORMAT = 'json'; |
||
24 | |||
25 | /** |
||
26 | * the bitly API domain. |
||
27 | */ |
||
28 | protected $domain; |
||
29 | |||
30 | /** |
||
31 | * bitly endpoint to shorten URL. |
||
32 | */ |
||
33 | protected $endpoint; |
||
34 | |||
35 | /** |
||
36 | * bitly app access token collected from the config file. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | private $access_token; |
||
41 | |||
42 | /** |
||
43 | * @param array $parameters |
||
44 | * @param Object $httpClient |
||
45 | */ |
||
46 | public function __construct($parameters, $httpClient = null) |
||
57 | |||
58 | /** |
||
59 | * set the attributes on the class after validating them. |
||
60 | * |
||
61 | * @param $parameters |
||
62 | */ |
||
63 | private function setParameters($parameters) |
||
69 | |||
70 | /** |
||
71 | * shorten the input $url and return the shorted version. |
||
72 | * |
||
73 | * @param $url |
||
74 | * |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function shorten($url) |
||
87 | |||
88 | /** |
||
89 | * Build the request parameters. |
||
90 | * |
||
91 | * @param $url |
||
92 | * |
||
93 | * @return array |
||
94 | */ |
||
95 | protected function parameters($url) |
||
103 | |||
104 | /** |
||
105 | * get the bitly shorten URL. |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | protected function url() |
||
113 | |||
114 | /** |
||
115 | * get a response object and return the short URL form the result. |
||
116 | * |
||
117 | * @param $response_object |
||
118 | * |
||
119 | * @return mixed |
||
120 | * |
||
121 | * @throws \Vinelab\UrlShortener\Validators\ResponseErrorException |
||
122 | */ |
||
123 | private function parse($response_object) |
||
131 | } |
||
132 |