diff options
author | Hannes Kindströmmer <hannes@kindstrommer.se> | 2017-03-03 16:10:20 +0100 |
---|---|---|
committer | Hannes Kindströmmer <hannes@kindstrommer.se> | 2017-03-03 16:10:20 +0100 |
commit | f21a0d262786459e5eb2bfbc1c009fc993ab12e4 (patch) | |
tree | a54701b5e6f59afea2512e2b5645d04f73f09bdd /src | |
parent | 02a8298f7b4f506e57d62ac29b9d3ac61dc41011 (diff) | |
download | ip1-php-sdk-f21a0d262786459e5eb2bfbc1c009fc993ab12e4.zip ip1-php-sdk-f21a0d262786459e5eb2bfbc1c009fc993ab12e4.tar.gz ip1-php-sdk-f21a0d262786459e5eb2bfbc1c009fc993ab12e4.tar.bz2 |
Add QoL functions and documentation
Added quaility of life functions that allow you to add whole arrays to OutGoingSMS objects. Also added more PHPDoc but PHPDoc seems to have a problem with generating class documentation files for classes that aren't abstract.
Signed-off-by: Hannes Kindströmmer <hannes@kindstrommer.se>
Diffstat (limited to 'src')
-rw-r--r-- | src/Core/UpdatableComponent.php | 3 | ||||
-rw-r--r-- | src/SMS/OutGoingSMS.php | 115 |
2 files changed, 109 insertions, 9 deletions
diff --git a/src/Core/UpdatableComponent.php b/src/Core/UpdatableComponent.php index e3082af..3dbe778 100644 --- a/src/Core/UpdatableComponent.php +++ b/src/Core/UpdatableComponent.php @@ -8,7 +8,8 @@ namespace IP1\RESTClient\Core; /** -* If an entity can be changed by the user or API after it has been added to the API that class implements this interface. +* If an entity can be changed by the user or the API after it has been added to the API +* that class implements this interface. * @package \IP1\RESTClient\Core */ interface UpdatableComponent extends ProcessedComponent diff --git a/src/SMS/OutGoingSMS.php b/src/SMS/OutGoingSMS.php index d182c9e..d73696f 100644 --- a/src/SMS/OutGoingSMS.php +++ b/src/SMS/OutGoingSMS.php @@ -5,11 +5,12 @@ * @author Hannes Kindströmmer <hannes@kindstrommer.se> * @copyright 2017 IP1 SMS */ -use IP1\RESTClient\Recipient\Contact; -use IP1\RESTClient\Recipient\Group; namespace IP1\RESTClient\SMS; +use IP1\RESTClient\Recipient\ProcessedContact; +use IP1\RESTClient\Recipient\Group; + /** * Class that is used when wanting to send SMSes to the API. * @link http://api.ip1sms.com/Help/Api/PUT-api-contacts-contact @@ -17,11 +18,29 @@ namespace IP1\RESTClient\SMS; */ class OutGoingSMS extends SMS implements \JsonSerializable { - private $numbers = []; - private $contacts = []; - private $groups = []; - private $email = false; /** + * Contains all the phone numbers the SMS should be sent to + * @var array $numbers phone numbers + */ + protected $numbers = []; + /** + * Contains all the ProcessedContact the SMS should be sent to. + * @var array $contacts + */ + protected $contacts = []; + /** + * Contains all the Group the SMS should be sent to. + * @var array $groups + */ + protected $groups = []; + /** + * If emails should be sent to the recipients aswell. + * @var bool $email + */ + protected $email = false; + + /** + * Adds the number to the recipient list. * @param string $number A number that should be added to the recipient list */ public function addNumber(string $number): void @@ -29,19 +48,99 @@ class OutGoingSMS extends SMS implements \JsonSerializable $this->numbers[] = $number; } /** - * @param Contact $contact A Contact that should be added to the recipient list + * Adds the given array of numbers to the recipient list. + * @param array $numbers An array of numbers(string) */ - public function addContact(Contact $contact): void + public function addAllNumbers(array $numbers): void + { + $this->numbers = array_merge($this->numbers, $numbers); + } + /** + * Removes the given index from the number recipient list + * @param int $index + */ + public function removeNumber(int $index) + { + unset($this->numbers[$index]); + $this->numbers = array_values($this->numbers); + } + /** + * Returns all the number recipient list. + * @return array + */ + public function getAllNumbers(): array + { + return $this->numbers; + } + /** + * Adds the ProcessedContact to the recipient list. + * @param ProcessedContact $contact A ProcessedContact that should be added to the recipient list + */ + public function addContact(ProcessedContact $contact): void { $this->contacts[] = $contact; } /** + * Removes the Contact in the given index and reindexes the array + * @param int $index + */ + public function removeContact(int $index): void + { + unset($this->contacts[$index]); + $this->contacts = array_values($this->contacts); + } + /** + * Adds the given array of contacts to the Contact recipient list. + * @param array An array of Contact + */ + public function addAllContacts(array $contacts): void + { + $this->contacts = array_merge($this->contacts, $contacts); + } + /** + * Adds the given Group to the recipient list. * @param Group $group A Group that should be added to the recipient list */ public function addGroup(Group $group): void { $this->groups[] = $group; } + /** + * Adds the given array of Groups to the recipient list. + * @param array $groups An array of Groups + */ + public function addAllGroups(array $groups): void + { + $this->groups = array_merge($this->groups, $groups); + } + /** + * Removes the Group in the given index and reindexes the array + * @param int $index + */ + public function removeGroup(int $index): void + { + unset($this->groups[$index]); + $this->groups = array_values($this->groups); + } + /** + * Returns the group in the given index. + * @param int $index + * @return Group + */ + public function getGroup(int $index): Group + { + return $this->groups[$index]; + } + /** + * Returns the Group recipient list. + * @return array An array of Group. + */ + public function getAllGroups(): array + { + return $this->groups; + } + + /** {@inheritDoc} */ public function jsonSerialize(): \stdClass { |