Skip to content

Commit fd3a910

Browse files
committed
added phpdoc blocks & some utilities
1 parent 4f73a98 commit fd3a910

12 files changed

+376
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
![](https://www.sms77.io/wp-content/uploads/2019/07/sms77-Logo-400x79.png "Sms77.io Logo")
2-
#sms77io PHP API Client
1+
![Sms77.io Logo](https://www.sms77.io/wp-content/uploads/2019/07/sms77-Logo-400x79.png "Sms77.io Logo")
2+
# sms77io PHP API Client
33

44
## Installation
55

src/Client.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

src/Exception/InvalidOptionalArgumentException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public function __construct($message, $code = 0, Exception $previous = null) {
99
parent::__construct($message, $code, $previous);
1010
}
1111

12+
/** @return string */
1213
public function __toString() {
1314
return __CLASS__ . ": [{$this->code}]: {$this->message}" . PHP_EOL;
1415
}

src/Exception/InvalidRequiredArgumentException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public function __construct($message, $code = 0, Exception $previous = null) {
99
parent::__construct($message, $code, $previous);
1010
}
1111

12+
/** @return string */
1213
public function __toString() {
1314
return __CLASS__ . ": [{$this->code}]: {$this->message}" . PHP_EOL;
1415
}

src/Reflectable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use ReflectionClass;
66

77
trait Reflectable {
8+
/** @return array */
89
public static function values() {
910
$reflector = new ReflectionClass(self::class);
1011
$constants = $reflector->getConstants();

src/SmsParams.php

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<?php
2+
3+
namespace Sms77\Api;
4+
5+
class SmsParams implements SmsParamsInterface {
6+
protected $debug = 0;
7+
protected $delay = 0;
8+
protected $details = 0;
9+
protected $flash = 0;
10+
protected $foreign_id;
11+
protected $from;
12+
protected $json = 0;
13+
protected $no_reload = 0;
14+
protected $performance_tracking = 0;
15+
protected $return_msg_id = 0;
16+
protected $text;
17+
protected $to;
18+
protected $ttl;
19+
protected $udh;
20+
protected $unicode = 0;
21+
protected $utf8 = 0;
22+
23+
/** @inheritDoc */
24+
public function getDebug() {
25+
return $this->debug;
26+
}
27+
28+
/** @param int $debug */
29+
public function setDebug($debug) {
30+
$this->debug = $debug;
31+
}
32+
33+
/** @inheritDoc */
34+
public function getDelay() {
35+
return $this->delay;
36+
}
37+
38+
/** @param int $delay */
39+
public function setDelay($delay) {
40+
$this->delay = $delay;
41+
}
42+
43+
/** @inheritDoc */
44+
public function getDetails() {
45+
return $this->details;
46+
}
47+
48+
/** @param int $details */
49+
public function setDetails($details) {
50+
$this->details = $details;
51+
}
52+
53+
/** @inheritDoc */
54+
public function getFlash() {
55+
return $this->flash;
56+
}
57+
58+
/** @param int $flash */
59+
public function setFlash($flash) {
60+
$this->flash = $flash;
61+
}
62+
63+
/** @inheritDoc */
64+
public function getForeignId() {
65+
return $this->foreign_id;
66+
}
67+
68+
/** @param mixed $foreign_id */
69+
public function setForeignId($foreign_id) {
70+
$this->foreign_id = $foreign_id;
71+
}
72+
73+
/** @inheritDoc */
74+
public function getFrom() {
75+
return $this->from;
76+
}
77+
78+
/** @param mixed $from */
79+
public function setFrom($from) {
80+
$this->from = $from;
81+
}
82+
83+
/** @inheritDoc */
84+
public function getJson() {
85+
return $this->json;
86+
}
87+
88+
/** @param int $json */
89+
public function setJson($json) {
90+
$this->json = $json;
91+
}
92+
93+
/** @inheritDoc */
94+
public function getNoReload() {
95+
return $this->no_reload;
96+
}
97+
98+
/** @param int $no_reload */
99+
public function setNoReload($no_reload) {
100+
$this->no_reload = $no_reload;
101+
}
102+
103+
/** @inheritDoc */
104+
public function getPerformanceTracking() {
105+
return $this->performance_tracking;
106+
}
107+
108+
/** @param int $performance_tracking */
109+
public function setPerformanceTracking($performance_tracking) {
110+
$this->performance_tracking = $performance_tracking;
111+
}
112+
113+
/** @inheritDoc */
114+
public function getReturnMsgId() {
115+
return $this->return_msg_id;
116+
}
117+
118+
/** @param int $return_msg_id */
119+
public function setReturnMsgId($return_msg_id) {
120+
$this->return_msg_id = $return_msg_id;
121+
}
122+
123+
/** @inheritDoc */
124+
public function getText() {
125+
return $this->text;
126+
}
127+
128+
/** @param string $text */
129+
public function setText($text) {
130+
$this->text = $text;
131+
}
132+
133+
/** @inheritDoc */
134+
public function getTo() {
135+
return $this->to;
136+
}
137+
138+
/** @param string $to */
139+
public function setTo($to) {
140+
$this->to = $to;
141+
}
142+
143+
/** @inheritDoc */
144+
public function getTtl() {
145+
return $this->ttl;
146+
}
147+
148+
/** @param mixed $ttl */
149+
public function setTtl($ttl) {
150+
$this->ttl = $ttl;
151+
}
152+
153+
/** @inheritDoc */
154+
public function getUdh() {
155+
return $this->udh;
156+
}
157+
158+
/** @param mixed $udh */
159+
public function setUdh($udh) {
160+
$this->udh = $udh;
161+
}
162+
163+
/** @inheritDoc */
164+
public function getUnicode() {
165+
return $this->unicode;
166+
}
167+
168+
/** @param int $unicode */
169+
public function setUnicode($unicode) {
170+
$this->unicode = $unicode;
171+
}
172+
173+
/** @inheritDoc */
174+
public function getUtf8() {
175+
return $this->utf8;
176+
}
177+
178+
/** @param int $utf8 */
179+
public function setUtf8($utf8) {
180+
$this->utf8 = $utf8;
181+
}
182+
}

0 commit comments

Comments
 (0)