summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHannes Kindströmmer <hannes@kindstrommer.se>2017-03-07 17:25:03 +0100
committerHannes Kindströmmer <hannes@kindstrommer.se>2017-03-07 17:25:03 +0100
commita118658f5a5277b68a739e1210179f4e8841abbb (patch)
tree54fa56c50fd1bbf05db92e4d768a40c0746c9e95 /src
parentd513e6ceeeffc96b0e61adfecdf666b13b5ebe2f (diff)
downloadip1-php-sdk-a118658f5a5277b68a739e1210179f4e8841abbb.zip
ip1-php-sdk-a118658f5a5277b68a739e1210179f4e8841abbb.tar.gz
ip1-php-sdk-a118658f5a5277b68a739e1210179f4e8841abbb.tar.bz2
Add useful functions
Diffstat (limited to 'src')
-rw-r--r--src/Recipient/ProcessedContact.php4
-rw-r--r--src/Recipient/RecipientFactory.php10
2 files changed, 13 insertions, 1 deletions
diff --git a/src/Recipient/ProcessedContact.php b/src/Recipient/ProcessedContact.php
index 646f7a4..890e857 100644
--- a/src/Recipient/ProcessedContact.php
+++ b/src/Recipient/ProcessedContact.php
@@ -108,4 +108,8 @@ class ProcessedContact extends Contact implements UpdatableComponent
);
return array_filter($returnArray);
}
+ public function __toString(): string
+ {
+ return json_encode($this->jsonSerialize());
+ }
}
diff --git a/src/Recipient/RecipientFactory.php b/src/Recipient/RecipientFactory.php
index d7178b5..7e7e094 100644
--- a/src/Recipient/RecipientFactory.php
+++ b/src/Recipient/RecipientFactory.php
@@ -126,7 +126,7 @@ class RecipientFactory
);
return $contact;
}
- public static function createProcessedGroupFromJSON(string $jsonContact): ProcessedGroup
+ public static function createProcessedGroupFromJSON(string $jsonGroup): ProcessedGroup
{
return self::createProcessedGroupFromStdClass(json_decode($jsonGroup));
}
@@ -165,4 +165,12 @@ class RecipientFactory
{
return self::createProcessedMembershipsFromStdClassArray(json_decode($membershipJSONArray));
}
+ public static function export(array $exportables): array
+ {
+ $returnArray = [];
+ foreach ($exportables as $value) {
+ $returnArray[] = $value->jsonSerialize();
+ }
+ return $returnArray;
+ }
}