From 3a8058ec09e205aaff21eab4554ee614cdf5ed82 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 3 Nov 2024 15:54:37 +0100 Subject: [PATCH] Extract visible_whitespace() into separate method in ActivityPubConversion --- src/Module/Debug/ActivityPubConversion.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Module/Debug/ActivityPubConversion.php b/src/Module/Debug/ActivityPubConversion.php index 251b9ad26e..ac0a0b664e 100644 --- a/src/Module/Debug/ActivityPubConversion.php +++ b/src/Module/Debug/ActivityPubConversion.php @@ -23,10 +23,7 @@ class ActivityPubConversion extends BaseModule protected function content(array $request = []): string { - function visible_whitespace($s) - { - return '
' . htmlspecialchars($s) . '
'; - } + $results = []; if (!empty($_REQUEST['source'])) { @@ -43,11 +40,11 @@ class ActivityPubConversion extends BaseModule $formatted = json_encode($source, JSON_PRETTY_PRINT); $results[] = [ 'title' => DI::l10n()->t('Formatted'), - 'content' => visible_whitespace(trim(var_export($formatted, true), "'")), + 'content' => $this->visible_whitespace(trim(var_export($formatted, true), "'")), ]; $results[] = [ 'title' => DI::l10n()->t('Source'), - 'content' => visible_whitespace(var_export($source, true)) + 'content' => $this->visible_whitespace(var_export($source, true)) ]; $activity = JsonLD::compact($source); if (!$activity) { @@ -55,7 +52,7 @@ class ActivityPubConversion extends BaseModule } $results[] = [ 'title' => DI::l10n()->t('Activity'), - 'content' => visible_whitespace(var_export($activity, true)) + 'content' => $this->visible_whitespace(var_export($activity, true)) ]; $type = JsonLD::fetchElement($activity, '@type'); @@ -107,14 +104,14 @@ class ActivityPubConversion extends BaseModule $results[] = [ 'title' => DI::l10n()->t('Object data'), - 'content' => visible_whitespace(var_export($object_data, true)) + 'content' => $this->visible_whitespace(var_export($object_data, true)) ]; $item = ActivityPub\Processor::createItem($object_data, true); $results[] = [ 'title' => DI::l10n()->t('Result Item'), - 'content' => visible_whitespace(var_export($item, true)) + 'content' => $this->visible_whitespace(var_export($item, true)) ]; } catch (\Throwable $e) { $results[] = [ @@ -134,4 +131,9 @@ class ActivityPubConversion extends BaseModule return $o; } + + private function visible_whitespace(string $s): string + { + return '
' . htmlspecialchars($s) . '
'; + } }