]> git.mxchange.org Git - friendica.git/commitdiff
Extract visible_whitespace() into separate method in ActivityPubConversion
authorArt4 <art4@wlabs.de>
Sun, 3 Nov 2024 14:54:37 +0000 (15:54 +0100)
committerArt4 <art4@wlabs.de>
Sun, 3 Nov 2024 14:54:37 +0000 (15:54 +0100)
src/Module/Debug/ActivityPubConversion.php

index 251b9ad26ebc018e7e62c7ed267c704ca95a2fc1..ac0a0b664e75208e58555cc956d0c869bfd44403 100644 (file)
@@ -23,10 +23,7 @@ class ActivityPubConversion extends BaseModule
 
        protected function content(array $request = []): string
        {
-               function visible_whitespace($s)
-               {
-                       return '<pre>' . htmlspecialchars($s) . '</pre>';
-               }
+
 
                $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 '<pre>' . htmlspecialchars($s) . '</pre>';
+       }
 }