/**
* Removes properties other than `objectType` and identifier from objects inside a statement.
* @param \stdClass $statement Statement to be formatted.
* @return \stdClass Formatted statement.
*/
public function identityStatement(\stdClass $statement)
{
$actor = $statement->actor;
// Processes an anonymous group or actor.
$is_anonymous_group = $actor->objectType === 'Group' && Helpers::getAgentIdentifier($actor) === null;
if ($is_anonymous_group) {
$actor->members = array_map(function (\stdClass $member) {
return $this->identityObject($member, Helpers::getAgentIdentifier($member));
}, $actor->members);
} else {
$actor = $this->identityObject($actor, Helpers::getAgentIdentifier($actor));
}
// Replace parts of the statements.
$statement->actor = $actor;
$statement->object = $this->identityObject($statement->object, Helpers::getAgentIdentifier($statement->object) ?: 'id');
return $statement;
}