]> git.mxchange.org Git - friendica.git/commitdiff
refactor of Friendica\Object\Api\Mastodon\Preferences class
authorArt4 <art4@wlabs.de>
Mon, 4 Nov 2024 12:30:26 +0000 (13:30 +0100)
committerArt4 <art4@wlabs.de>
Mon, 4 Nov 2024 12:30:26 +0000 (13:30 +0100)
src/Object/Api/Mastodon/Preferences.php

index 7447f5fa74e68e87f30e291cdfabbf8b56e17c55..68f3c922a801b9796e37cc809d6297c90caa930b 100644 (file)
@@ -17,16 +17,30 @@ use Friendica\BaseDataTransferObject;
  */
 class Preferences extends BaseDataTransferObject
 {
-//     /** @var string (Enumerable, oneOf) */
-//     protected $posting_default_visibility;
-//     /** @var bool */
-//     protected $posting_default_sensitive;
-//     /** @var string (ISO 639-1 language two-letter code), or null*/
-//     protected $posting_default_language;
-//     /** @var string (Enumerable, oneOf) */
-//     protected $reading_expand_media;
-//     /** @var bool */
-//     protected $reading_expand_spoilers;
+       /**
+        * @var string (Enumerable, oneOf)
+        */
+       private $visibility;
+
+       /**
+        * @var bool
+        */
+       private $sensitive;
+
+       /**
+        * @var string (ISO 639-1 language two-letter code), or null
+        */
+       private $language;
+
+       /**
+        * @var string (Enumerable, oneOf)
+        */
+       private $media;
+
+       /**
+        * @var bool
+        */
+       private $spoilers;
 
        /**
         * Creates a preferences record.
@@ -39,10 +53,26 @@ class Preferences extends BaseDataTransferObject
         */
        public function __construct(string $visibility, bool $sensitive, string $language, string $media, bool $spoilers)
        {
-               $this->{'posting:default:visibility'} = $visibility;
-               $this->{'posting:default:sensitive'}  = $sensitive;
-               $this->{'posting:default:language'}   = $language;
-               $this->{'reading:expand:media'}       = $media;
-               $this->{'reading:expand:spoilers'}    = $spoilers;
+               $this->visibility = $visibility;
+               $this->sensitive = $sensitive;
+               $this->language = $language;
+               $this->media = $media;
+               $this->spoilers = $spoilers;
+       }
+
+       /**
+        * Returns the current entity as an array
+        *
+        * @return array
+        */
+       public function toArray(): array
+       {
+               return [
+                       'posting:default:visibility' => $this->visibility,
+                       'posting:default:sensitive' => $this->sensitive,
+                       'posting:default:language' => $this->language,
+                       'reading:expand:media' => $this->media,
+                       'reading:expand:spoilers' => $this->spoilers,
+               ];
        }
 }