@@ -17,15 +17,27 @@ class Client {
1717 /* @var string $sendWith */
1818 private $ sendWith ;
1919
20+ /**
21+ * @param $apiKey
22+ * @param string $sendWith
23+ */
2024 public function __construct ($ apiKey , $ sendWith = 'php-api ' ) {
2125 $ this ->apiKey = $ apiKey ;
2226 $ this ->sendWith = $ sendWith ;
2327 }
2428
29+ /**
30+ * @return bool|string
31+ */
2532 public function balance () {
2633 return $ this ->request ('balance ' , $ this ->buildOptions ([]));
2734 }
2835
36+ /**
37+ * @param $path
38+ * @param array $options
39+ * @return bool|string
40+ */
2941 private function request ($ path , $ options = []) {
3042 $ curl_get_contents = static function ($ url ) {
3143 $ ch = curl_init ();
@@ -39,6 +51,11 @@ private function request($path, $options = []) {
3951 return $ curl_get_contents (self ::BASE_URI . '/ ' . $ path . '? ' . http_build_query ($ options ));
4052 }
4153
54+ /**
55+ * @param array $required
56+ * @param array $extra
57+ * @return array
58+ */
4259 private function buildOptions (array $ required , array $ extra = []) {
4360 $ required = array_merge ($ required , [
4461 'p ' => $ this ->apiKey ,
@@ -48,6 +65,12 @@ private function buildOptions(array $required, array $extra = []) {
4865 return array_merge ($ required , $ extra );
4966 }
5067
68+ /**
69+ * @param $action
70+ * @param array $extra
71+ * @return bool|string
72+ * @throws Exception\InvalidRequiredArgumentException
73+ */
5174 public function contacts ($ action , array $ extra = []) {
5275 $ options = $ this ->buildOptions ([
5376 'action ' => $ action ,
@@ -58,6 +81,13 @@ public function contacts($action, array $extra = []) {
5881 return $ this ->request ('contacts ' , $ options );
5982 }
6083
84+ /**
85+ * @param $type
86+ * @param $number
87+ * @param array $extra
88+ * @return bool|string
89+ * @throws Exception\InvalidRequiredArgumentException
90+ */
6191 public function lookup ($ type , $ number , array $ extra = []) {
6292 $ options = $ this ->buildOptions ([
6393 'type ' => $ type ,
@@ -69,6 +99,11 @@ public function lookup($type, $number, array $extra = []) {
6999 return $ this ->request ('lookup ' , $ options );
70100 }
71101
102+ /**
103+ * @param array $extra
104+ * @return bool|string
105+ * @throws Exception\InvalidRequiredArgumentException
106+ */
72107 public function pricing (array $ extra = []) {
73108 $ options = $ this ->buildOptions ([], $ extra );
74109
@@ -77,6 +112,13 @@ public function pricing(array $extra = []) {
77112 return $ this ->request ('pricing ' , $ options );
78113 }
79114
115+ /**
116+ * @param $to
117+ * @param $text
118+ * @param array $extra
119+ * @return bool|string
120+ * @throws Exception\InvalidRequiredArgumentException
121+ */
80122 public function sms ($ to , $ text , array $ extra = []) {
81123 $ options = $ this ->buildOptions ([
82124 'to ' => $ to ,
@@ -88,6 +130,11 @@ public function sms($to, $text, array $extra = []) {
88130 return $ this ->request ('sms ' , $ options );
89131 }
90132
133+ /**
134+ * @param $msgId
135+ * @return bool|string
136+ * @throws Exception\InvalidRequiredArgumentException
137+ */
91138 public function status ($ msgId ) {
92139 $ options = $ this ->buildOptions ([
93140 'msg_id ' => $ msgId ,
@@ -98,6 +145,12 @@ public function status($msgId) {
98145 return $ this ->request ('status ' , $ options );
99146 }
100147
148+ /**
149+ * @param $number
150+ * @param array $extra
151+ * @return bool|string
152+ * @throws Exception\InvalidRequiredArgumentException
153+ */
101154 public function validateForVoice ($ number , array $ extra = []) {
102155 $ options = $ this ->buildOptions ([
103156 'number ' => $ number ,
@@ -108,6 +161,13 @@ public function validateForVoice($number, array $extra = []) {
108161 return $ this ->request ('validate_for_voice ' , $ options );
109162 }
110163
164+ /**
165+ * @param $to
166+ * @param $text
167+ * @param array $extra
168+ * @return bool|string
169+ * @throws Exception\InvalidRequiredArgumentException
170+ */
111171 public function voice ($ to , $ text , array $ extra = []) {
112172 $ options = $ this ->buildOptions ([
113173 'to ' => $ to ,
0 commit comments