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:----HhGAMMlKX6wwnxT3Qa/UBColGwbh112xtIFyn4zqmRcWTsdoMWhQwTo62ByRkCeEd+TW06NJsLXzjuR3oXijKwXNLJbYbHwIPULl0ssy/574IZB6S2pKh3pecVKbE+ecfciGj2xYJlWnSEbaVCFYimXwurhVFggeNIWI0Lz+r/fdUkviALmxxeXH6apCuiuIFHqyCDpwWyG+CNNGr1bbSh46Wr9C5y7j8R0JwGGAhcJ9zsZNqydBESO9EgXLO1T1cXw419niradiZQhaEDrmDq+ZzM2WPw+iFRnqQzKZKB0Ygfn0KYyQ7iGZRvzFGEpgtsYNRiH0fAnH2nmDsjaTh0qfNjKiZY6xk8eEBBi2klQddw+ScbS9/rSq+q2/TUlRWVDL5DHQI6iysek+mdBUN/0Ho4krWOn2CioAKj2Auw/YCKyHnxHleF+pEoJLShECZ50SIYFzqlS43D3GtkE2KLH8Hu35onS6zBdmNnOpKi0V6Tau5O4lyw2es0gYv4ew6TkKBc/qi5oDWER5V2386J02Px9bnKjrqiK48iriVlpLBkpoC5tETA58oXnad4sf7Lt/LTPX1DSJWvMTjO/OVpaogQURICL/Mng0MjnTrFjal2kCNgDcO44eXzM3KtX4oCT9jD1OGBVUE8qk4sbwnVL6+tFWtM0v6x5tuP0d8c4=----ATTACHMENT:----ODk0OTYyNTQ4MTI5Njk3OSAxNzcwOTY2OTU4MTg4NTU5IDM5NDIwMzY2MzE4NTQyODM=