X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fpoco.php;h=baea5b33b03f79701bf253cc144da530c65445b9;hb=9143d4f38493da81328317100b34a37dd67fde54;hp=d7b082163ee21eb4199be57d17463f49f21f7fc5;hpb=47f31bce47b182aa55c02c7872d7e473d3ab10f2;p=quix0rs-gnu-social.git diff --git a/lib/poco.php b/lib/poco.php index d7b082163e..baea5b33b0 100644 --- a/lib/poco.php +++ b/lib/poco.php @@ -241,4 +241,42 @@ class PoCo $url->outputTo($xo); } } + + /** + * Output a Portable Contact as an array suitable for serializing + * as JSON + * + * @return $array the PoCo array + */ + + function asArray() + { + $poco = array(); + + $poco['preferredUsername'] = $this->preferredUsername; + $poco['displayName'] = $this->displayName; + + if (!empty($this->note)) { + $poco['note'] = $this->note; + } + + if (!empty($this->address)) { + $poco['addresses'] = $this->address->asArray(); + } + + if (!empty($this->urls)) { + + $urls = array(); + + foreach ($this->urls as $url) { + $urls[] = $url->asArray(); + } + + $poco['urls'] = $urls; + } + + return $poco; + } + } +