diff options
author | Hannes Kindströmmer <hannes@kindstrommer.se> | 2017-03-16 11:54:00 +0100 |
---|---|---|
committer | Hannes Kindströmmer <hannes@kindstrommer.se> | 2017-03-16 11:54:00 +0100 |
commit | f8e58c51d752e656cb7bf34b29093892794caea4 (patch) | |
tree | 06edc82ce31b9e2effcb37224e7b50c0194153f3 | |
parent | c0bc7046d55616e00e88db58d0baee6c1f9a53d4 (diff) | |
parent | 9e2904fb56f7cf9e924b140530f15f26c02dba35 (diff) | |
download | ip1-php-sdk-f8e58c51d752e656cb7bf34b29093892794caea4.zip ip1-php-sdk-f8e58c51d752e656cb7bf34b29093892794caea4.tar.gz ip1-php-sdk-f8e58c51d752e656cb7bf34b29093892794caea4.tar.bz2 |
Merge branch 'hotfix/0.1.11-beta'0.1.11-beta
-rw-r--r-- | src/Core/Communicator.php | 32 | ||||
-rw-r--r-- | src/Core/ProcessableComponentInterface.php (renamed from src/Core/ProcessableComponent.php) | 2 | ||||
-rw-r--r-- | src/Core/ProcessedComponentInterface.php (renamed from src/Core/ProcessedComponent.php) | 2 | ||||
-rw-r--r-- | src/Core/UpdatableComponentInterface.php (renamed from src/Core/UpdatableComponent.php) | 2 | ||||
-rw-r--r-- | src/Recipient/Contact.php | 4 | ||||
-rw-r--r-- | src/Recipient/Group.php | 8 | ||||
-rw-r--r-- | src/Recipient/Membership.php | 4 | ||||
-rw-r--r-- | src/Recipient/MembershipRelationInterface.php (renamed from src/Recipient/MembershipRelation.php) | 2 | ||||
-rw-r--r-- | src/Recipient/ProcessedContact.php | 10 | ||||
-rw-r--r-- | src/Recipient/ProcessedGroup.php | 8 | ||||
-rw-r--r-- | src/Recipient/ProcessedMembership.php | 5 | ||||
-rw-r--r-- | src/Recipient/RecipientFactory.php | 4 | ||||
-rw-r--r-- | src/SMS/LoggedOutGoingSMS.php | 6 | ||||
-rw-r--r-- | src/SMS/OutGoingSMS.php | 4 | ||||
-rw-r--r-- | src/SMS/ProcessedOutGoingSMS.php | 4 |
15 files changed, 48 insertions, 49 deletions
diff --git a/src/Core/Communicator.php b/src/Core/Communicator.php index cfaaf38..0764df1 100644 --- a/src/Core/Communicator.php +++ b/src/Core/Communicator.php @@ -12,9 +12,9 @@ namespace IP1\RESTClient\Core; use IP1\RESTClient\Recipient\RecipientFactory; -use IP1\RESTClient\Core\ProcessedComponent; -use IP1\RESTClient\Core\UpdatableComponent; -use IP1\RESTClient\Core\ProcessableComponent; +use IP1\RESTClient\Core\ProcessedComponentInterface; +use IP1\RESTClient\Core\UpdatableComponentInterface; +use IP1\RESTClient\Core\ProcessableComponentInterface; /** * Handles request to the API and converts the responses into the data classes. @@ -40,12 +40,12 @@ class Communicator } /** * Adds the param to the API and returns the response as the corresponding object. - * @param ProcessableComponent $component A Contact, Group, Membership or OutGoingSMS. - * @return ProcessedComponent ProcessedContact, ProcessedGroup, PrcessedMembership or a ClassValidatinArray + * @param ProcessableComponentInterface $component A Contact, Group, Membership or OutGoingSMS. + * @return ProcessedComponentInterface ProcessedContact, ProcessedGroup, PrcessedMembership or a ClassValidatinArray * filled with ProcessedOutGoingSMS. * @throws \InvalidArgumentException When param isn't any of the classes listed in param args. */ - public function add(ProcessableComponent $component): ProcessedComponent + public function add(ProcessableComponentInterface $component): ProcessedComponentInterface { switch (get_class($component)) { case "IP1\RESTClient\Recipient\Contact": @@ -69,12 +69,12 @@ class Communicator } /** * Removes the param to the API and returns the response as the corresponding object. - * @param ProcessedComponent $component A Contact, Group, Membership. - * @return ProcessedComponent ProcessedContact, ProcessedGroup, PrcessedMembership or a ClassValidatinArray + * @param ProcessedComponentInterface $component A Contact, Group, Membership. + * @return ProcessedComponentInterface ProcessedContact, ProcessedGroup, PrcessedMembership or a ClassValidatinArray * filled with ProcessedOutGoingSMS. * @throws \InvalidArgumentException When param isn't any of the classes listed in param args. */ - public function remove(ProcessedComponent $component): ProcessedComponent + public function remove(ProcessedComponentInterface $component): ProcessedComponentInterface { switch (get_class($component)) { case "IP1\RESTClient\Recipient\ProcessedContact": @@ -94,11 +94,11 @@ class Communicator } /** * Edits the param to the API and returns the response as the corresponding object. - * @param UpdatableComponent $component A Contact, Group, Membership. - * @return UpdatableComponent ProcessedContact, ProcessedGroup or PrcessedMembership. + * @param UpdatableComponentInterface $component A Contact, Group, Membership. + * @return UpdatableComponentInterface ProcessedContact, ProcessedGroup or PrcessedMembership. * @throws \InvalidArgumentException When param isn't any of the classes listed in param args. */ - public function edit(UpdatableComponent $component): UpdatableComponent + public function edit(UpdatableComponentInterface $component): UpdatableComponentInterface { switch (get_class($component)) { case "IP1\RESTClient\Recipient\ProcessedContact": @@ -122,7 +122,7 @@ class Communicator } /** - * Fetches a ProcessedComponent(s) from the given URI. + * Fetches a ProcessedComponentInterface(s) from the given URI. * @param string $endPoint API URI. * @return string JSON API Response. */ @@ -134,7 +134,7 @@ class Communicator /** * Adds the content object to the endpoint and returns a processed version of given object. * @param string $endPoint API URI. - * @param \JsonSerializable $content The ProcessableComponent that is to be posted to the API. + * @param \JsonSerializable $content The ProcessableComponentInterface that is to be posted to the API. * @return string JSON API Response. */ public function post(string $endPoint, \JsonSerializable $content): string @@ -153,7 +153,7 @@ class Communicator return $this->sendRequest($parsedEndPoint, "DELETE"); } /** - * Replaces a ProcessedComponent with the arguments given. + * Replaces a ProcessedComponentInterface with the arguments given. * @param string $endPoint API URI. * @param \JsonSerializable $content The JsonSerializable that is to be PUT to the API. * @return string JSON API Response. @@ -161,7 +161,7 @@ class Communicator public function put(string $endPoint, \JsonSerializable $content): string { $parsedEndPoint = self::parseEndPoint($endPoint); - return $this->sendRequest($parsedEndPoint, "PUT", json_encode($component)); + return $this->sendRequest($parsedEndPoint, "PUT", json_encode($content)); } /** * Turns the given endPoint string into a usable. diff --git a/src/Core/ProcessableComponent.php b/src/Core/ProcessableComponentInterface.php index 987dd0c..c133cee 100644 --- a/src/Core/ProcessableComponent.php +++ b/src/Core/ProcessableComponentInterface.php @@ -16,7 +16,7 @@ namespace IP1\RESTClient\Core; * All objects that are possible to send to the Communicator implement this or any child class. * @package \IP1\RESTClient\Core */ -interface ProcessableComponent extends \JsonSerializable +interface ProcessableComponentInterface extends \JsonSerializable { /** diff --git a/src/Core/ProcessedComponent.php b/src/Core/ProcessedComponentInterface.php index e593600..5e14e83 100644 --- a/src/Core/ProcessedComponent.php +++ b/src/Core/ProcessedComponentInterface.php @@ -15,7 +15,7 @@ namespace IP1\RESTClient\Core; * All responses from the API implements this class. * @package \IP1\RESTClient\Core */ -interface ProcessedComponent extends ProcessableComponent +interface ProcessedComponentInterface extends ProcessableComponentInterface { /** diff --git a/src/Core/UpdatableComponent.php b/src/Core/UpdatableComponentInterface.php index 993a569..7ed353f 100644 --- a/src/Core/UpdatableComponent.php +++ b/src/Core/UpdatableComponentInterface.php @@ -16,7 +16,7 @@ namespace IP1\RESTClient\Core; * that class implements this interface. * @package \IP1\RESTClient\Core */ -interface UpdatableComponent extends ProcessedComponent +interface UpdatableComponentInterface extends ProcessedComponentInterface { /** * Returns when the component was updated last. diff --git a/src/Recipient/Contact.php b/src/Recipient/Contact.php index 4afa14a..3fd5c3d 100644 --- a/src/Recipient/Contact.php +++ b/src/Recipient/Contact.php @@ -11,12 +11,12 @@ */ namespace IP1\RESTClient\Recipient; -use IP1\RESTClient\Core\ProcessableComponent; +use IP1\RESTClient\Core\ProcessableComponentInterface; /** * Contact class that represents the JSON that is sent to the API when adding a new Contact */ -class Contact implements ProcessableComponent +class Contact implements ProcessableComponentInterface { /** * The contacts first name. diff --git a/src/Recipient/Group.php b/src/Recipient/Group.php index d074398..133976e 100644 --- a/src/Recipient/Group.php +++ b/src/Recipient/Group.php @@ -11,12 +11,12 @@ */ namespace IP1\RESTClient\Recipient; -use IP1\RESTClient\Core\ProcessableComponent; +use IP1\RESTClient\Core\ProcessableComponentInterface; /** * Used to group contacts together with the Membership class. */ -class Group implements ProcessableComponent +class Group implements ProcessableComponentInterface { /** * Name of Group. @@ -70,7 +70,7 @@ class Group implements ProcessableComponent public function setName(string $name):void { if (empty($name)) { - throw new InvalidArgumentException("Group name can not be empty"); + throw new \InvalidArgumentException("Group name can not be empty"); } $this->name = $name; } @@ -84,7 +84,7 @@ class Group implements ProcessableComponent public function setColor(string $color): void { if (!preg_match("/^#([A-Fa-f0-9]{6})$/", $color)) { - throw new InvalidArgumentException($color. " is not a valid hexadecimal color"); + throw new \InvalidArgumentException($color. " is not a valid hexadecimal color"); } $this->color = $color; } diff --git a/src/Recipient/Membership.php b/src/Recipient/Membership.php index 2d42939..4bd3be8 100644 --- a/src/Recipient/Membership.php +++ b/src/Recipient/Membership.php @@ -11,12 +11,12 @@ */ namespace IP1\RESTClient\Recipient; -use IP1\RESTClient\Core\ProcessableComponent; +use IP1\RESTClient\Core\ProcessableComponentInterface; /** * Membership is the bridge between ProcessedGroup and ProcessedContact. */ -class Membership implements ProcessableComponent +class Membership implements ProcessableComponentInterface { /** diff --git a/src/Recipient/MembershipRelation.php b/src/Recipient/MembershipRelationInterface.php index 945ca2e..bb159c2 100644 --- a/src/Recipient/MembershipRelation.php +++ b/src/Recipient/MembershipRelationInterface.php @@ -19,7 +19,7 @@ use IP1\RESTClient\Core\ClassValidationArray; * @link http://api.ip1sms.com/Help/Api/GET-api-memberships * @package \IP1\RESTClient\Recipient */ -interface MembershipRelation +interface MembershipRelationInterface { /** * Returns an array of all the memberships diff --git a/src/Recipient/ProcessedContact.php b/src/Recipient/ProcessedContact.php index cdd7436..87a637f 100644 --- a/src/Recipient/ProcessedContact.php +++ b/src/Recipient/ProcessedContact.php @@ -11,17 +11,17 @@ */ namespace IP1\RESTClient\Recipient; -use IP1\RESTClient\Core\UpdatableComponent; +use IP1\RESTClient\Core\UpdatableComponentInterface; use IP1\RESTClient\Recipient\Membership; use IP1\RESTClient\Recipient\RecipientFactory; -use IP1\RESTClient\Recipient\MembershipRelation; +use IP1\RESTClient\Recipient\MembershipRelationInterface; use IP1\RESTClient\Core\Communicator; use IP1\RESTClient\Core\ClassValidationArray; /** * A Contact that has been added to the API. Has all the options that a normal Contact has. */ -class ProcessedContact extends Contact implements UpdatableComponent, MembershipRelation +class ProcessedContact extends Contact implements UpdatableComponentInterface, MembershipRelationInterface { /** * The ID of the Contact given by the API. @@ -109,7 +109,7 @@ class ProcessedContact extends Contact implements UpdatableComponent, Membership */ public function getMemberships(Communicator $communicator = null): ClassValidationArray { - if ($communicator != null) { + if ($communicator !== null) { $membershipJSON = $communicator->get("api/contacts/".$this->contactID."/memberships"); $membershipStd = json_decode($membershipJSON); $memberships = []; @@ -130,7 +130,7 @@ class ProcessedContact extends Contact implements UpdatableComponent, Membership */ public function getGroups(Communicator $communicator = null): ClassValidationArray { - if ($communicator != null) { + if ($communicator !== null) { $groupsJSON = $communicator->get('api/contacts/'.$this->contactID. '/groups'); $groupStd = json_decode($groupsJSON); $groups = RecipientFactory::createProcessedGroupsFromStdClassArray($groupStd); diff --git a/src/Recipient/ProcessedGroup.php b/src/Recipient/ProcessedGroup.php index bbe0985..eef4f79 100644 --- a/src/Recipient/ProcessedGroup.php +++ b/src/Recipient/ProcessedGroup.php @@ -12,14 +12,14 @@ namespace IP1\RESTClient\Recipient; use IP1\RESTClient\Core\Communicator; -use IP1\RESTClient\Core\UpdatableComponent; +use IP1\RESTClient\Core\UpdatableComponentInterface; use IP1\RESTClient\Core\ClassValidationArray; use IP1\RESTClient\Recipient\ProcessedMembership; /** * */ -class ProcessedGroup extends Group implements UpdatableComponent, MembershipRelation +class ProcessedGroup extends Group implements UpdatableComponentInterface, MembershipRelationInterface { /** * The ID of the Group given by the API. @@ -106,7 +106,7 @@ class ProcessedGroup extends Group implements UpdatableComponent, MembershipRela */ public function getMemberships(Communicator $communicator = null): ClassValidationArray { - if ($communicator != null) { + if ($communicator !== null) { $membershipJSON = $communicator->get("api/groups/".$this->groupID."/memberships"); $membershipStd = json_decode($membershipJSON); $memberships = []; @@ -135,7 +135,7 @@ class ProcessedGroup extends Group implements UpdatableComponent, MembershipRela */ public function getContacts(Communicator $communicator = null): ClassValidationArray { - if ($communicator != null) { + if ($communicator !== null) { $contactStd = $communicator->get('api/groups/'.$this->groupID. '/contacts'); $contactStd = json_decode($contactStd); $contacts = RecipientFactory::createProcessedGroupsFromStdClassArray($contactStd); diff --git a/src/Recipient/ProcessedMembership.php b/src/Recipient/ProcessedMembership.php index 41b72a1..28160d6 100644 --- a/src/Recipient/ProcessedMembership.php +++ b/src/Recipient/ProcessedMembership.php @@ -11,14 +11,13 @@ */ namespace IP1\RESTClient\Recipient; -use IP1\RESTClient\Core\Communicator; -use IP1\RESTClient\Core\ProcessedComponent; +use IP1\RESTClient\Core\ProcessedComponentInterface; /** * ProcessedMembership class. * Is the relation between contacts and groups. */ -class ProcessedMembership extends Membership implements ProcessedComponent +class ProcessedMembership extends Membership implements ProcessedComponentInterface { /** diff --git a/src/Recipient/RecipientFactory.php b/src/Recipient/RecipientFactory.php index 4bfae7b..05de224 100644 --- a/src/Recipient/RecipientFactory.php +++ b/src/Recipient/RecipientFactory.php @@ -224,8 +224,8 @@ class RecipientFactory $stdClassSMS->Message, $stdClassSMS->To, $stdClassSMS->ID, - new DateTime($stdClassSMS->Created), - new DateTime($stdClassSMS->Updated), + new \DateTime($stdClassSMS->Created), + new \DateTime($stdClassSMS->Updated), $stdClassSMS->Status, $stdClassSMS->StatusDescription, $stdClassSMS->BundleID diff --git a/src/SMS/LoggedOutGoingSMS.php b/src/SMS/LoggedOutGoingSMS.php index 9fc39b1..eccf260 100644 --- a/src/SMS/LoggedOutGoingSMS.php +++ b/src/SMS/LoggedOutGoingSMS.php @@ -9,14 +9,14 @@ * @link http://api.ip1sms.com/Help * @link https://github.com/iP1SMS/ip1-php-sdk */ -use IP1\RESTClient\Core\UpdatableComponent; - namespace IP1\RESTClient\SMS; +use IP1\RESTClient\Core\UpdatableComponentInterface; + /** * The response you will get when sending an OutGoingSMS. One instance per recipient. */ -class LoggedOutGoingSMS extends ProcessedOutGoingSMS implements UpdatableComponent +class LoggedOutGoingSMS extends ProcessedOutGoingSMS implements UpdatableComponentInterface { /** * Stores when the sms was created in UTC. diff --git a/src/SMS/OutGoingSMS.php b/src/SMS/OutGoingSMS.php index e75474f..1ef0703 100644 --- a/src/SMS/OutGoingSMS.php +++ b/src/SMS/OutGoingSMS.php @@ -14,12 +14,12 @@ namespace IP1\RESTClient\SMS; use IP1\RESTClient\Recipient\ProcessedContact; use IP1\RESTClient\Recipient\Group; -use IP1\RESTClient\Core\ProcessableComponent; +use IP1\RESTClient\Core\ProcessableComponentInterface; /** * Class that is used when wanting to send SMSes to the API. */ -class OutGoingSMS extends SMS implements ProcessableComponent +class OutGoingSMS extends SMS implements ProcessableComponentInterface { /** * Contains all the phone numbers the SMS should be sent to. diff --git a/src/SMS/ProcessedOutGoingSMS.php b/src/SMS/ProcessedOutGoingSMS.php index b6e56d7..7e19c3f 100644 --- a/src/SMS/ProcessedOutGoingSMS.php +++ b/src/SMS/ProcessedOutGoingSMS.php @@ -12,12 +12,12 @@ namespace IP1\RESTClient\SMS; -use IP1\RESTClient\Core\UpdatableComponent; +use IP1\RESTClient\Core\UpdatableComponentInterface; /** * The response from the API when you post an SMS to the API */ -class ProcessedOutGoingSMS extends SMS implements UpdatableComponent +class ProcessedOutGoingSMS extends SMS implements UpdatableComponentInterface { /** * The ID of the SMS provided by the API. |