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:----ZuemrKB4tQmVGeJy4r4d0D+rZypPoZ98F/F9V/AAQieNts5MVC4WtwXYMUL2g+cTsMI2u4JhhTOIXoyutecBV3cLGvJPnIl05uR2oGbPkCFAPt9t2ZEyeU2D70QGa33qly0f4ZP1wv23kevUHeS//dYQdLusrF7ne2i+mAT00glAFO63uU/w8oEsO1ChUDD1cJSXGE1OQi2Cb1b1HcPbJbEwZ5+aWuATgn227cAAzhe8MBbQMfDu2E0bFJMJku2l7GZd17I+oY4SR4iJIDVaVORxLcBnfIUMKRy320qUJ10nTUI0wt+fWt4koaBdJdpFn3NRsgq6Qb5ZMaFU8MtlJLnGsqKTY1Gxwyph6y0Kh5ZanfwwC2Oh0+1O0DgNGedvAXlWzRR2zutvhNXRvlX7LzS+4d3tKUKD51t7o5YS4xxNaWZr1slWeYVVEuLA+mP0n30eg+Acn4lkAx/9r8BWyJJ7YuNf9JudzrH49+QYriZ5Jo/o0DNA4yGV9S7c6shW48wj99nKOT3FiKUnCnWinUpDlTbiATu+8geYJrBVpJx9zHmmYQFo+ymYWE71wnBGcpH6vohJAuPlj8axbHoDwi92nWhWhVFS41Ke4k2sF6s6Gb8Lw1f6uZjAQgfQI9Ry8ztHYh8k2nDJIntwXW34Aj+Rja/kwsOXrxvs+ha+SdA=----ATTACHMENT:----MTE1ODA5NzczNDU5NTQ2IDE1ODA3ODM0MTM3MzA0MSA4ODg3MjcxMzA3MTU4NzY3