Skip to content

Commit 26c9b5d

Browse files
authored
Merge pull request #64 from Bandwidth/SWI-2615
SWI-2615
2 parents 2757021 + fa2400b commit 26c9b5d

File tree

80 files changed

+1132
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1132
-452
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [windows-2022, windows-2019, ubuntu-20.04, ubuntu-22.04]
20-
php-version: [7.4, 8.0]
20+
php-version: [7.4, 8.0, 8.1, 8.2]
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v3

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
vendor
33
composer.lock
44
.phpunit.result.cache
5-
composer.phar
5+
composer.phar
6+
.idea

src/APIHelper.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class APIHelper
1717
{
1818
/**
1919
* Replaces template parameters in the given url
20-
* @param string $url The query string builder to replace the template parameters
21-
* @param array $parameters The parameters to replace in the url
20+
* @param string $url The query string builder to replace the template parameters
21+
* @param array $parameters The parameters to replace in the url
2222
* @return string The processed url
2323
*/
24-
public static function appendUrlWithTemplateParameters($url, $parameters, $encode = true)
24+
public static function appendUrlWithTemplateParameters(string $url, array $parameters, $encode = true): string
2525
{
2626
//perform parameter validation
2727
if (is_null($url) || !is_string($url)) {
@@ -55,11 +55,11 @@ public static function appendUrlWithTemplateParameters($url, $parameters, $encod
5555

5656
/**
5757
* Appends the given set of parameters to the given query string
58-
* @param string $queryBuilder The query url string to append the parameters
59-
* @param array $parameters The parameters to append
58+
* @param string $queryBuilder The query url string to append the parameters
59+
* @param array $parameters The parameters to append
6060
* @return void
6161
*/
62-
public static function appendUrlWithQueryParameters(&$queryBuilder, $parameters)
62+
public static function appendUrlWithQueryParameters(string &$queryBuilder, array $parameters)
6363
{
6464
//perform parameter validation
6565
if (is_null($queryBuilder) || !is_string($queryBuilder)) {
@@ -80,9 +80,9 @@ public static function appendUrlWithQueryParameters(&$queryBuilder, $parameters)
8080

8181
/**
8282
* Validates and processes the given Url
83-
* @param string $url The given Url to process
83+
* @param string $url The given Url to process
8484
* @return string Pre-processed Url as string */
85-
public static function cleanUrl($url)
85+
public static function cleanUrl(string $url): string
8686
{
8787
//perform parameter validation
8888
if (is_null($url) || !is_string($url)) {
@@ -106,12 +106,12 @@ public static function cleanUrl($url)
106106

107107
/**
108108
* Deserialize a Json string
109-
* @param string $json A valid Json string
109+
* @param string $json A valid Json string
110110
* @param mixed $instance Instance of an object to map the json into
111-
* @param boolean $isArray Is the Json an object array?
111+
* @param boolean $isArray Is the Json an object array?
112112
* @return mixed Decoded Json
113113
*/
114-
public static function deserialize($json, $instance = null, $isArray = false)
114+
public static function deserialize(string $json, $instance = null, bool $isArray = false)
115115
{
116116
if ($instance == null) {
117117
return json_decode($json, true);
@@ -127,10 +127,10 @@ public static function deserialize($json, $instance = null, $isArray = false)
127127

128128
/**
129129
* Check if an array isAssociative (has string keys)
130-
* @param array $arr A valid array
130+
* @param array $arr A valid array
131131
* @return boolean True if the array is Associative, false if it is Indexed
132132
*/
133-
private static function isAssociative($arr)
133+
private static function isAssociative(array $arr): bool
134134
{
135135
foreach ($arr as $key => $value) {
136136
if (is_string($key)) {
@@ -143,10 +143,10 @@ private static function isAssociative($arr)
143143

144144
/**
145145
* Prepare a model for form encoding
146-
* @param JsonSerializable $model A valid instance of JsonSerializable
146+
* @param JsonSerializable $model A valid instance of JsonSerializable
147147
* @return array The model as a map of key value pairs
148148
*/
149-
public static function prepareFormFields($model)
149+
public static function prepareFormFields(JsonSerializable $model)
150150
{
151151
if (!$model instanceof JsonSerializable) {
152152
return $model;

src/Configuration.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ public function getBaseUrl()
261261

262262
/**
263263
* Get the base uri for a given server in the current environment
264-
* @param string $server Server name
264+
* @param string $server Server name
265265
* @return string Base URI
266266
*/
267-
public function getBaseUri($server = Servers::DEFAULT_)
267+
public function getBaseUri(string $server = Servers::DEFAULT_)
268268
{
269269
return APIHelper::appendUrlWithTemplateParameters(
270270
static::$environmentsMap[$this->environment][$server],

src/Http/ApiResponse.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class ApiResponse
3232

3333
/**
3434
* Create a new instance of a HttpResponse
35-
* @param int $statusCode Response code
35+
* @param int $statusCode Response code
3636
* @param array $headers Map of headers
3737
* @param mixed $result The deserialized response
3838
*/
39-
public function __construct($statusCode, array $headers, $result)
39+
public function __construct(int $statusCode, array $headers, $result)
4040
{
4141
$this->statusCode = $statusCode;
4242
$this->headers = $headers;

src/Http/HttpRequest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class HttpRequest
3838

3939
/**
4040
* Create a new HttpRequest
41-
* @param string $httpMethod Http method
41+
* @param string|null $httpMethod Http method
4242
* @param array|null $headers Map of headers
43-
* @param string $queryUrl Query url
43+
* @param string|null $queryUrl Query url
4444
* @param array|null $parameters Map of parameters sent
4545
*/
46-
public function __construct($httpMethod = null, array $headers = null, $queryUrl = null, array $parameters = null)
46+
public function __construct(string $httpMethod = null, array $headers = null, string $queryUrl = null, array $parameters = null)
4747
{
4848
$this->httpMethod = $httpMethod;
4949
$this->headers = $headers;
@@ -64,7 +64,7 @@ public function getHttpMethod()
6464
* Set http method
6565
* @param string $httpMethod Http Method as defined in HttpMethod class
6666
*/
67-
public function setHttpMethod($httpMethod)
67+
public function setHttpMethod(string $httpMethod)
6868
{
6969
$this->httpMethod = $httpMethod;
7070
}
@@ -100,7 +100,7 @@ public function getQueryUrl()
100100
* Set query url
101101
* @param string $queryUrl Query url
102102
*/
103-
public function setQueryUrl($queryUrl)
103+
public function setQueryUrl(string $queryUrl)
104104
{
105105
$this->queryUrl = $queryUrl;
106106
}
@@ -118,7 +118,7 @@ public function getParameters()
118118
* Set parameters
119119
* @param array $parameters Map of input parameters
120120
*/
121-
public function setParameters($parameters)
121+
public function setParameters(array $parameters)
122122
{
123123
$this->parameters = $parameters;
124124
}

src/Http/HttpResponse.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class HttpResponse
3232

3333
/**
3434
* Create a new instance of a HttpResponse
35-
* @param int $statusCode Response code
35+
* @param int $statusCode Response code
3636
* @param array $headers Map of headers
3737
* @param string $rawBody Raw response body
3838
*/
39-
public function __construct($statusCode, array $headers, $rawBody)
39+
public function __construct(int $statusCode, array $headers, string $rawBody)
4040
{
4141
$this->statusCode = $statusCode;
4242
$this->headers = $headers;

src/Messaging/Controllers/APIController.php

+36-36
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public function __construct($config, $httpCallBack = null)
3434
* Gets a list of your media files. No query parameters are supported.
3535
*
3636
* @param string $accountId User's account ID
37-
* @param string $continuationToken (optional) Continuation token used to retrieve subsequent media.
37+
* @param string|null $continuationToken (optional) Continuation token used to retrieve subsequent media.
3838
* @return ApiResponse response from the API call
3939
* @throws APIException Thrown if API call fails
4040
*/
4141
public function listMedia(
42-
$accountId,
43-
$continuationToken = null
42+
string $accountId,
43+
string $continuationToken = null
4444
) {
4545

4646
//prepare query string for API call
@@ -128,8 +128,8 @@ public function listMedia(
128128
* @throws APIException Thrown if API call fails
129129
*/
130130
public function getMedia(
131-
$accountId,
132-
$mediaId
131+
string $accountId,
132+
string $mediaId
133133
) {
134134

135135
//prepare query string for API call
@@ -215,17 +215,17 @@ public function getMedia(
215215
* @param string $mediaId The user supplied custom media ID
216216
* @param string $body TODO: type description here
217217
* @param string $contentType (optional) The media type of the entity-body
218-
* @param string $cacheControl (optional) General-header field is used to specify directives that MUST be obeyed
218+
* @param string|null $cacheControl (optional) General-header field is used to specify directives that MUST be obeyed
219219
* by all caching mechanisms along the request/response chain.
220220
* @return ApiResponse response from the API call
221221
* @throws APIException Thrown if API call fails
222222
*/
223223
public function uploadMedia(
224-
$accountId,
225-
$mediaId,
226-
$body,
227-
$contentType = 'application/octet-stream',
228-
$cacheControl = null
224+
string $accountId,
225+
string $mediaId,
226+
string $body,
227+
string $contentType = 'application/octet-stream',
228+
string $cacheControl = null
229229
) {
230230

231231
//prepare query string for API call
@@ -318,8 +318,8 @@ public function uploadMedia(
318318
* @throws APIException Thrown if API call fails
319319
*/
320320
public function deleteMedia(
321-
$accountId,
322-
$mediaId
321+
string $accountId,
322+
string $mediaId
323323
) {
324324

325325
//prepare query string for API call
@@ -399,35 +399,35 @@ public function deleteMedia(
399399
/**
400400
* Gets a list of messages based on query parameters.
401401
*
402-
* @param string $accountId User's account ID
403-
* @param string $messageId (optional) The ID of the message to search for. Special characters need to be
402+
* @param string $accountId User's account ID
403+
* @param string|null $messageId (optional) The ID of the message to search for. Special characters need to be
404404
* encoded using URL encoding
405-
* @param string $sourceTn (optional) The phone number that sent the message
406-
* @param string $destinationTn (optional) The phone number that received the message
407-
* @param string $messageStatus (optional) The status of the message. One of RECEIVED, QUEUED, SENDING, SENT,
405+
* @param string|null $sourceTn (optional) The phone number that sent the message
406+
* @param string|null $destinationTn (optional) The phone number that received the message
407+
* @param string|null $messageStatus (optional) The status of the message. One of RECEIVED, QUEUED, SENDING, SENT,
408408
* FAILED, DELIVERED, ACCEPTED, UNDELIVERED
409-
* @param integer $errorCode (optional) The error code of the message
410-
* @param string $fromDateTime (optional) The start of the date range to search in ISO 8601 format. Uses the
409+
* @param integer|null $errorCode (optional) The error code of the message
410+
* @param string|null $fromDateTime (optional) The start of the date range to search in ISO 8601 format. Uses the
411411
* message receive time. The date range to search in is currently 14 days.
412-
* @param string $toDateTime (optional) The end of the date range to search in ISO 8601 format. Uses the
412+
* @param string|null $toDateTime (optional) The end of the date range to search in ISO 8601 format. Uses the
413413
* message receive time. The date range to search in is currently 14 days.
414-
* @param string $pageToken (optional) A base64 encoded value used for pagination of results
415-
* @param integer $limit (optional) The maximum records requested in search result. Default 100. The sum of
414+
* @param string|null $pageToken (optional) A base64 encoded value used for pagination of results
415+
* @param integer|null $limit (optional) The maximum records requested in search result. Default 100. The sum of
416416
* limit and after cannot be more than 10000
417417
* @return ApiResponse response from the API call
418418
* @throws APIException Thrown if API call fails
419419
*/
420420
public function getMessages(
421-
$accountId,
422-
$messageId = null,
423-
$sourceTn = null,
424-
$destinationTn = null,
425-
$messageStatus = null,
426-
$errorCode = null,
427-
$fromDateTime = null,
428-
$toDateTime = null,
429-
$pageToken = null,
430-
$limit = null
421+
string $accountId,
422+
string $messageId = null,
423+
string $sourceTn = null,
424+
string $destinationTn = null,
425+
string $messageStatus = null,
426+
int $errorCode = null,
427+
string $fromDateTime = null,
428+
string $toDateTime = null,
429+
string $pageToken = null,
430+
int $limit = null
431431
) {
432432

433433
//prepare query string for API call
@@ -524,14 +524,14 @@ public function getMessages(
524524
/**
525525
* Endpoint for sending text messages and picture messages using V2 messaging.
526526
*
527-
* @param string $accountId User's account ID
527+
* @param string $accountId User's account ID
528528
* @param Models\MessageRequest $body TODO: type description here
529529
* @return ApiResponse response from the API call
530530
* @throws APIException Thrown if API call fails
531531
*/
532532
public function createMessage(
533-
$accountId,
534-
$body
533+
string $accountId,
534+
Models\MessageRequest $body
535535
) {
536536

537537
//prepare query string for API call

src/Messaging/Models/BandwidthCallbackMessage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct()
6666
/**
6767
* Encode this object to JSON
6868
*/
69-
public function jsonSerialize()
69+
public function jsonSerialize(): array
7070
{
7171
$json = array();
7272
$json['time'] = $this->time;

src/Messaging/Models/BandwidthMessage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function __construct()
111111
/**
112112
* Encode this object to JSON
113113
*/
114-
public function jsonSerialize()
114+
public function jsonSerialize(): array
115115
{
116116
$json = array();
117117
$json['id'] = $this->id;

src/Messaging/Models/BandwidthMessageItem.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function __construct()
136136
/**
137137
* Encode this object to JSON
138138
*/
139-
public function jsonSerialize()
139+
public function jsonSerialize(): array
140140
{
141141
$json = array();
142142
$json['messageId'] = $this->messageId;

src/Messaging/Models/BandwidthMessagesList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct()
4545
/**
4646
* Encode this object to JSON
4747
*/
48-
public function jsonSerialize()
48+
public function jsonSerialize(): array
4949
{
5050
$json = array();
5151
$json['totalCount'] = $this->totalCount;

src/Messaging/Models/DeferredResult.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct()
3838
/**
3939
* Encode this object to JSON
4040
*/
41-
public function jsonSerialize()
41+
public function jsonSerialize(): array
4242
{
4343
$json = array();
4444
$json['result'] = $this->result;

src/Messaging/Models/Media.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct()
4545
/**
4646
* Encode this object to JSON
4747
*/
48-
public function jsonSerialize()
48+
public function jsonSerialize(): array
4949
{
5050
$json = array();
5151
$json['content'] = $this->content;

src/Messaging/Models/MessageRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct()
7878
/**
7979
* Encode this object to JSON
8080
*/
81-
public function jsonSerialize()
81+
public function jsonSerialize(): array
8282
{
8383
$json = array();
8484
$json['applicationId'] = $this->applicationId;

src/Messaging/Models/PageInfo.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __construct()
5252
/**
5353
* Encode this object to JSON
5454
*/
55-
public function jsonSerialize()
55+
public function jsonSerialize(): array
5656
{
5757
$json = array();
5858
$json['prevPage'] = $this->prevPage;

0 commit comments

Comments
 (0)