activitypub/src/ContentNation/ActivityPub/Common/OrderedCollectionPage.php

56 lines
1.2 KiB
PHP

<?php
namespace ContentNation\ActivityPub\Common;
require_once("OrderedCollection.php");
class OrderedCollectionPage extends OrderedCollection {
private string $next = '';
private string $prev = '';
private string $partOf = '';
public function __construct() {
parent::__construct();
parent::addContext('https://www.w3.org/ns/activitystreams');
}
/**
* convert internal state to php array
* @return array<string,mixed>
*/
public function toObject() {
$return = parent::toObject();
if ($this->next !== '') {
$return['next'] = $this->next;
}
if ($this->prev !== '') {
$return['prev'] = $this->prev;
}
if ($this->partOf !== '') {
$return['partOf'] = $this->partOf;
}
return $return;
}
/**
* create object from json
* @param array<string,mixed> $json input json
* @return bool true on success
*/
public function fromJson($json) : bool {
return parent::fromJson($json);
}
public function setNext(string $url) : void {
$this->next = $url;
}
public function setPrev(string $url) : void {
$this->prev = $url;
}
public function setPartOf(string $url) : void {
$this->partOf = $url;
}
}