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

78 lines
1.4 KiB
PHP

<?php
namespace ContentNation\ActivityPub\Common;
require_once("Document.php");
class Note extends APObject {
/**
* sender
*
* @var string
*/
private $sender = "";
/**
* receiver
*
* @var string
*/
private $receiver = "";
public function __construct() {
parent::__construct("Note");
}
/**
* set sender
* @param string $sender note sender
* @return Note current instance
*/
public function setSender(string $sender) : Note {
$this->sender = $sender;
return $this;
}
/**
* get sender
* @return string sender
*/
public function getSender() : string {
return $this->sender;
}
/**
* set receiver
* @param string $receiver note receiver
* @return Note current instance
*/
public function setReceiver(string $receiver) : Note {
$this->receiver = $receiver;
return $this;
}
/**
* convert internal state to php array
* @return array<string,mixed>
*/
public function toObject() {
$return = parent::toObject();
if ($this->sender !== "") {
$return['sender'] = $this->sender;
}
if ($this->receiver !== "") {
$return['receiver'] = $this->receiver;
}
return $return;
}
/**
* create object from json
* @param mixed $json input json
*/
public function fromJson($json) : bool {
if (!parent::fromJson($json))
return false;
$this->receiver = "";
return true;
}
}