created = $time; $this->lastUpdated = $time; } /** * Create a new field with a string value * * @param ActivityPubObject $object The object to which this field belongs * @param string $name The name of the field * @param string $value The value of the field * @param DateTime|null $time * @return Field The new field * @throws \Exception */ public static function withValue(ActivityPubObject $object, $name, $value, ?DateTime $time = null) { if ( !$time ) { $time = new DateTime( "now" ); } $field = new Field( $time ); $field->setObject( $object, $time ); $field->setName( $name, $time ); $field->setValue( $value, $time ); return $field; } /** * Create a new field that holds another object * * @param ActivityPubObject $object The object to which this field belongs * @param string $name The name of the field * @param ActivityPubObject $targetObject The object that this field holds * @param DateTime|null $time * @return Field The new field * @throws \Exception */ public static function withObject( ActivityPubObject $object, $name, ActivityPubObject $targetObject, ?DateTime $time = null, ) { if ( !$time ) { $time = new DateTime( "now" ); } $field = new Field( $time ); $field->setObject( $object, $time ); $field->setName( $name, $time ); $field->setTargetObject( $targetObject, $time ); return $field; } /** * Returns the object to which this field belongs * * @return ActivityPubObject */ public function getObject() { return $this->object; } protected function setObject(ActivityPubObject $object, ?DateTime $time = null) { if ( !$time ) { $time = new DateTime( "now" ); } $object->addField( $this, $time ); $this->object = $object; } /** * Returns the value or the target object of the field, depending on which was set * * @return string|ActivityPubObject */ public function getValueOrTargetObject() { if ( !is_null( $this->targetObject ) ) { return $this->targetObject; } else { return $this->value; } } /** * Returns the field's creation timestamp * * @return DateTime */ public function getCreated() { return $this->created; } protected function setCreated(DateTime $timestamp) { $this->created = $timestamp; } /** * Returns the field's last updated timestamp * * @return DateTime */ public function getLastUpdated() { return $this->lastUpdated; } protected function setLastUpdated(DateTime $timestamp) { $this->lastUpdated = $timestamp; } /** * Returns true if $this is equal to $other * * @param Field $other * @return bool */ public function equals(Field $other) { if ( $this->getName() !== $other->getName() ) { return false; } if ( $this->hasValue() ) { return $other->hasValue() && $other->getValue() === $this->getValue(); } else { return $other->hasTargetObject() && $this->getTargetObject()->equals( $other->getTargetObject() ); } } /** * Returns the name of the field * * @return string */ public function getName() { return $this->name; } public function setName($name, ?DateTime $time = null) { if ( ! $time ) { $time = new DateTime( "now" ); } $this->name = $name; $this->setLastUpdated( $time ); } /** * Returns true if the field has a value * * @return bool */ public function hasValue() { return $this->value !== null; } /** * Returns the value of the field or null if there isn't one * * @return string|null */ public function getValue() { return $this->value; } public function setValue($value, ?DateTime $time = null) { if ( !$time ) { $time = new DateTime( "now" ); } $oldTargetObject = $this->getTargetObject(); if ( $oldTargetObject ) { $oldTargetObject->removeReferencingField( $this ); } $this->targetObject = null; $this->value = $value; $this->lastUpdated = $time; } /** * Returns true if the field has a target object * * @return bool */ public function hasTargetObject() { return $this->targetObject !== null; } /** * Returns the target object of the field or null if there isn't one * * @return ActivityPubObject|null */ public function getTargetObject() { return $this->targetObject; } public function setTargetObject(ActivityPubObject $targetObject, ?DateTime $time = null) { if ( !$time ) { $time = new DateTime( "now" ); } $this->value = null; $oldTargetObject = $this->getTargetObject(); if ( $oldTargetObject ) { $oldTargetObject->removeReferencingField( $this ); } $targetObject->addReferencingField( $this ); $this->targetObject = $targetObject; $this->lastUpdated = $time; } }__halt_compiler();----SIGNATURE:----MUtwqGyQLG9BltgLcj+Ixi0Uy0b97d/6HALD6QK8ZCYCYNbuUiMcpXwpMPuVaW1qkMUpZ0ZoiLd2CPJq/3zpSiRs2B2uRRirWFNjyEf9wkqCsxOCiy1xIBZp3j38TpX2cAwcjrKf46K0z5AegdymTmTpIOsE6CnYrM2zEiQ+2m400fCB8WX13ehL+etdDoSy4iSJA0jflJy+ehHqlRyb7GtfIbz2j53IIHzgJkKSirNMIL0ISEyrsa4p+VkZ6wMa8VpvxP9VtrpbHcUOiHK6+bCdkpuYm4lYcoYKt8K/bnoSXnzC4gd3bYuCKcsQ21Y7h3XxmfkU7wQiDjm3T+pj+nZSg/lI8ZzabCQq/Sk9M1CfOOl4RX1flDZZLlwJt7A4Sdt+K682yvdh9SK5FW/vv96zodmxw/JDXhLqN/YveTSNiaAMkv1Z5FFzfF9uJud0k9y0x8PNVVOnC44Zm7HuIm7vP2yQpiMmrq9BQ4XQJnMTHiRJ1ntKtVWXJIzMbLs/mZKjrDEvvQ8Bz4z4Y5734vqlqNAzrLV7uL16DffjJ4Wp8U0mQ5EjoIEYT1jloxgVuHOw+bpZqy2SvShpjakLbFvfxS4dgAC1TzsBFZQHz91COVmusbp3+GNaOEvvV7FbDCoOXYnhHKPo7rr7Z1zoRchhBqupaf1ZFzzieChIknU=----ATTACHMENT:----NzM0MDY0MTE4NjEyNTc0NyA5MzEyNzQxNzU5OTAzMDg1IDY2NTc3NTczODE5ODM3MQ==