protected function replacePlaceholders(string $description, Activity $activity) : string
{
return preg_replace_callback('/:[a-z0-9._-]+/i', function ($match) use($activity) {
$match = $match[0];
$attribute = (string) string($match)->between(':', '.');
if (!in_array($attribute, ['subject', 'causer', 'properties'])) {
return $match;
}
$propertyName = substr($match, strpos($match, '.') + 1);
$attributeValue = $activity->{$attribute};
$attributeValue = $attributeValue->toArray();
return array_get($attributeValue, $propertyName, $match);
}, $description);
}