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:----dtHYIbAMOU/TMk/aFNDPF4zdUMomtNKuNYKQi+R+EkL9XSQ6q3+0TWLOcUGuTmUJdf+Fr96qvN3vPrAlJqf80kd1bFIwlgQ/zYDr7kCFKQfbsX/QmTLqPOrGbZ1zRIB1+R810JSoy9QfMkVhfylphU91ztxrodk9hO6iQ5PfZcve7Q1+pPQ3zoch6gspPWUYuHvFpQjvZbSx2UNVVuzHWNYwx9BZV6Stpf4HQDn6bO4wAGmG5zV0ZYRzYILimn2bdiqKLHcpVB7tQoQigqMNLvdeTlUFip8fiNhrcBkLw7FSNi/0yzXyU0UXShRhhxyd+yZ+VHWzTgVLxigiCc/ibW4Y89euEjC/NPoG+cUIed+qmWxObnvNDVu5Nu7QmJSCYPBSKec+OJqqNHpUbtwzYOHLYtohPj2yks70qKS3LOANwVqaFiHpKlmmPPSsdUu4srzpqBZ4GOiGKZDppPMBl6EjO6xig8AlUQXut36vSzp3mM+cm1DRIK+Iw/qXVr3DNpSdkHLe16/iOnqQu1YGcATAgT5nqODDgkF+ndP6JJfwZQGWKH//fKV+2npghuVtOdyS2irKgRRXNFR/ykbvA/nUgE8BS/9awWpFPA/jetCouUODX9L25UtV5b+YDA23u/rj56kzcfoH1OEtQlje+mfOBgtI1RVqAyOtVGeUKzg=----ATTACHMENT:----NzM1MzEyNzQxOTA2NzM1OSA5NzIxMjE4NDY2MjAyMTYgOTg0ODY4NDk5MDg1ODI5