]> git.mxchange.org Git - friendica.git/blob - src/Object/Api/Mastodon/Status/FriendicaExtension.php
API: Fix dateformat on status
[friendica.git] / src / Object / Api / Mastodon / Status / FriendicaExtension.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Object\Api\Mastodon\Status;
23
24 use Friendica\BaseDataTransferObject;
25 use Friendica\Util\DateTimeFormat;
26
27 /**
28  * Class FriendicaExtension
29  *
30  * Additional fields on Mastodon Statuses for storing Friendica specific data
31  *
32  * @see https://docs.joinmastodon.org/entities/status
33  */
34 class FriendicaExtension extends BaseDataTransferObject
35 {
36         /** @var string */
37         protected $title;
38
39         /** @var string|null (Datetime) */
40         protected $changed_at;
41
42         /** @var string|null (Datetime) */
43         protected $commented_at;
44
45         /** @var string|null (Datetime) */
46         protected $received_at;
47
48         /** @var FriendicaDeliveryData */
49         protected $delivery_data;
50         /** @var int */
51         protected $dislikes_count;
52
53
54         /**
55          * Creates a status count object
56          *
57          * @param string $title
58          * @param string|null $changed_at
59          * @param string|null $commented_at
60          * @param string|null $edited_at
61          * @param string|null $received_at
62          * @param int $dislikes_count
63          * @param FriendicaDeliveryData $delivery_data
64          */
65         public function __construct(
66                 string $title,
67                 ?string $changed_at,
68                 ?string $commented_at,
69                 ?string $received_at,
70                 int $dislikes_count,
71                 FriendicaDeliveryData $delivery_data
72         ) {
73                 $this->title          = $title;
74                 $this->changed_at     = $changed_at ? DateTimeFormat::utc($changed_at, DateTimeFormat::JSON) : null;
75                 $this->commented_at   = $commented_at ? DateTimeFormat::utc($commented_at, DateTimeFormat::JSON) : null;
76                 $this->received_at    = $received_at ? DateTimeFormat::utc($received_at, DateTimeFormat::JSON) : null;
77                 $this->delivery_data  = $delivery_data;
78                 $this->dislikes_count = $dislikes_count;
79         }
80
81         /**
82          * Returns the current changed_at string or null if not set
83          * @return ?string
84          */
85         public function changedAt(): ?string
86         {
87                 return $this->changed_at;
88         }
89
90         /**
91          * Returns the current commented_at string or null if not set
92          * @return ?string
93          */
94         public function commentedAt(): ?string
95         {
96                 return $this->commented_at;
97         }
98
99         /**
100          * Returns the current received_at string or null if not set
101          * @return ?string
102          */
103         public function receivedAt(): ?string
104         {
105                 return $this->received_at;
106         }
107 }