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:----ao1DKowMPwX9jpAbqOKFge8OQHSbCHhOXy1g7kTwWVdQ3NAVrhByaTxlDF6RB5R7GpL/824tiXWGGjg/tuFpolpAvvxfnVpPj8i+kfeTslcllMBxAGgJ4nTCkb7nFj/aE+hH9olBYSiBYI6ohw1gpKI5BYtSYd0t/Lw5fuF+3MHkyjP++hip1NrOXkzXbudqTtOY03gJR4GRSy90FvWs6pQPTkugc+OgkKh3J148eTzabB12z0+CbcQ9QtqeKIUmPDjF2t/4L4tT4raptl+lePWZshzStN4TCxNjtB5koeRk9NzaSo0i2sDmzAl+RkiArXs65dRyrkuxur0egE+12Bpdn5n0z/OqHcnmsKnU85PmdnW8xQQOaEElvl1U2Nph12TeB83ae47XlqtH/wWbGRGFngSs+8UGegKMgAAXCAGGF4x5+C2wTTnjRv0u9tFunh+fHMIDAGBeRM5n1XklVBlCOHSjEkBaNQ9Nym91cjWYLaWujdlNKqxUnfYMj9PCNOe9iPU/XxvlNH1X+m5pFYVgnxSTUrjDuAbzReqAHXbLfQs/Lq6Vg43hWJnK+2O4vphm6Y38GYX5im1M6f2bzmwQ8GC15reOGMmS+BQvOCc6KEzIMzmDXlMN8UMZWcCO4/dV3eXln/GCm6fw+Deo061DTRxEyN/cWJVCubCgDkI=----ATTACHMENT:----NzM1MDg5MTQyNzM0NTE1NCA2OTc2NjcyNjQ5NDUzOTUwIDE5MjgwMTc2MTUxMDQ1NTA=