activitystreamslink.php 814 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * A class for representing links in JSON Activities
  4. *
  5. * @category Feed
  6. * @package StatusNet
  7. * @author Zach Copley <zach@status.net>
  8. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  9. * @link http://status.net/
  10. */
  11. class ActivityStreamsLink
  12. {
  13. private $linkDict;
  14. function __construct($url = null, $rel = null, $mediaType = null)
  15. {
  16. // links MUST have a URL
  17. if (empty($url)) {
  18. throw new Exception('Links must have a URL.');
  19. }
  20. $this->linkDict = array(
  21. 'url' => $url,
  22. 'rel' => $rel, // extension
  23. 'type' => $mediaType // extension
  24. );
  25. }
  26. function asArray()
  27. {
  28. return array_filter($this->linkDict);
  29. }
  30. }