1
1
<?php
2
-
2
+ /**
3
+ * Link Shrink
4
+ *
5
+ * Licensed under The MIT License
6
+ * For full copyright and license information, please see the LICENSE file
7
+ * Redistributions of files must retain the above copyright notice.
8
+ *
9
+ * @author Matthew Nessworthy <[email protected] >
10
+ * @copyright Copyright (c) Matthew Nessworthy
11
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
12
+ * @link https://github.com/devmatt/link-shrink
13
+ */
3
14
namespace LinkShrink \Provider ;
4
15
5
16
use Ivory \HttpAdapter \HttpAdapterInterface ;
@@ -38,15 +49,16 @@ public function __construct(HttpAdapterInterface $adapter, $apiKey = null)
38
49
$ this ->apiKey = $ apiKey ;
39
50
}
40
51
52
+ /**
53
+ * @inheritdoc
54
+ */
41
55
public function getName ()
42
56
{
43
57
return 'google ' ;
44
58
}
45
59
46
60
/**
47
- * @param $url
48
- *
49
- * @return mixed
61
+ * @inheritdoc
50
62
*/
51
63
public function getShortenedUrl ($ url )
52
64
{
@@ -57,9 +69,7 @@ public function getShortenedUrl($url)
57
69
}
58
70
59
71
/**
60
- * @param $url
61
- *
62
- * @return mixed
72
+ * @inheritdoc
63
73
*/
64
74
public function getExpandedUrl ($ url )
65
75
{
@@ -68,6 +78,9 @@ public function getExpandedUrl($url)
68
78
return $ this ->executeExpandUrlQuery ($ apiUrl );
69
79
}
70
80
81
+ /**
82
+ * @return string
83
+ */
71
84
protected function buildShortenUrl ()
72
85
{
73
86
$ url = static ::SHORTEN_ENDPOINT_URL ;
@@ -79,7 +92,7 @@ protected function buildShortenUrl()
79
92
}
80
93
81
94
/**
82
- * @param $url
95
+ * @param string $url
83
96
*
84
97
* @return string
85
98
*/
@@ -92,7 +105,13 @@ protected function buildShortenUrlParameters($url)
92
105
return json_encode ($ parameters );
93
106
}
94
107
95
- protected function executeShortenUrlQuery ($ query , $ parameters )
108
+ /**
109
+ * @param string $query
110
+ * @param array|string $parameters
111
+ *
112
+ * @return string
113
+ */
114
+ protected function executeShortenUrlQuery ($ query , $ parameters = array ())
96
115
{
97
116
$ content = (string ) $ this ->getAdapter ()->post ($ query , array ('Content-Type: application/json ' ),
98
117
$ parameters )->getBody ();
@@ -113,7 +132,7 @@ protected function executeShortenUrlQuery($query, $parameters)
113
132
}
114
133
115
134
/**
116
- * @param $url
135
+ * @param string $url
117
136
*
118
137
* @return string
119
138
*/
@@ -129,6 +148,11 @@ protected function buildExpandedUrl($url)
129
148
return static ::EXPAND_ENDPOINT_URL . '? ' . http_build_query ($ parameters );
130
149
}
131
150
151
+ /**
152
+ * @param string $query
153
+ *
154
+ * @return string
155
+ */
132
156
protected function executeExpandUrlQuery ($ query )
133
157
{
134
158
$ content = (string ) $ this ->getAdapter ()->get ($ query )->getBody ();
0 commit comments