| Total Complexity | 8 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Coverage | 85.71% |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class OutboundSMSRequest extends SMSClientRequest |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Request body |
||
| 12 | * |
||
| 13 | * @var array |
||
| 14 | */ |
||
| 15 | protected $body; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Recipient number |
||
| 19 | * |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $sender; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * OutboundSMSObjectRequest constructor. |
||
| 26 | * @param $message |
||
| 27 | * @param $recipientNumber |
||
| 28 | * @param $senderNumber |
||
| 29 | * @param $senderName |
||
| 30 | * @throws \Exception |
||
| 31 | */ |
||
| 32 | 1 | public function __construct($message, $recipientNumber, $senderNumber, $senderName = null) |
|
|
|
|||
| 33 | { |
||
| 34 | 1 | $this->throwsExceptionIfEmpty($recipientNumber, $senderNumber); |
|
| 35 | |||
| 36 | 1 | $this->body = ['outboundSMSMessageRequest' => [ |
|
| 37 | 1 | 'address' => 'tel:'.$this->normalizePhoneNumber($recipientNumber), |
|
| 38 | 1 | 'senderAddress' => $this->sender = 'tel:'.$this->normalizePhoneNumber($senderNumber), |
|
| 39 | 1 | 'outboundSMSTextMessage' => [ 'message' => $message ?: ''] |
|
| 40 | ] |
||
| 41 | ]; |
||
| 42 | |||
| 43 | 1 | // if ($senderName) { |
|
| 44 | // $this->body['outboundSMSMessageRequest']['senderName'] = urlencode($senderName); |
||
| 45 | // } |
||
| 46 | 1 | } |
|
| 47 | |||
| 48 | /** |
||
| 49 | * @inherit |
||
| 50 | * |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | 1 | public function method() |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @inherit |
||
| 60 | * |
||
| 61 | * @return string |
||
| 62 | * @throws \Exception |
||
| 63 | */ |
||
| 64 | 1 | public function uri() |
|
| 65 | { |
||
| 66 | 1 | return static::BASE_URI."/smsmessaging/v1/outbound/".urlencode($this->sender)."/requests"; |
|
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @inherit |
||
| 71 | * |
||
| 72 | * @return array |
||
| 73 | */ |
||
| 74 | 1 | public function options() |
|
| 75 | { |
||
| 76 | return [ |
||
| 77 | 1 | 'headers' => ["Content-Type" => "Application/json"], |
|
| 78 | 1 | 'body' => json_encode($this->body) |
|
| 79 | ]; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @param $recipientNumber |
||
| 84 | * @param $senderNumber |
||
| 85 | * @throws \Exception |
||
| 86 | */ |
||
| 87 | 1 | private function throwsExceptionIfEmpty($recipientNumber, $senderNumber) |
|
| 95 | } |
||
| 96 | 1 | } |
|
| 97 | } |
||
| 98 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.