]> git.mxchange.org Git - friendica.git/blob - src/Object/Notification/Notification.php
Merge pull request #10586 from annando/app-user2
[friendica.git] / src / Object / Notification / Notification.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2021, 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\Notification;
23
24 /**
25  * A view-only object for printing item notifications to the frontend
26  */
27 class Notification implements \JsonSerializable
28 {
29         const SYSTEM   = 'system';
30         const PERSONAL = 'personal';
31         const NETWORK  = 'network';
32         const INTRO    = 'intro';
33         const HOME     = 'home';
34
35         /** @var string */
36         private $label = '';
37         /** @var string */
38         private $link = '';
39         /** @var string */
40         private $image = '';
41         /** @var string */
42         private $url = '';
43         /** @var string */
44         private $text = '';
45         /** @var string */
46         private $when = '';
47         /** @var string */
48         private $ago = '';
49         /** @var boolean */
50         private $seen = false;
51
52         /**
53          * @return string
54          */
55         public function getLabel()
56         {
57                 return $this->label;
58         }
59
60         /**
61          * @return string
62          */
63         public function getLink()
64         {
65                 return $this->link;
66         }
67
68         /**
69          * @return string
70          */
71         public function getImage()
72         {
73                 return $this->image;
74         }
75
76         /**
77          * @return string
78          */
79         public function getUrl()
80         {
81                 return $this->url;
82         }
83
84         /**
85          * @return string
86          */
87         public function getText()
88         {
89                 return $this->text;
90         }
91
92         /**
93          * @return string
94          */
95         public function getWhen()
96         {
97                 return $this->when;
98         }
99
100         /**
101          * @return string
102          */
103         public function getAgo()
104         {
105                 return $this->ago;
106         }
107
108         /**
109          * @return bool
110          */
111         public function isSeen()
112         {
113                 return $this->seen;
114         }
115
116         public function __construct(array $data)
117         {
118                 $this->label = $data['label'] ?? '';
119                 $this->link  = $data['link'] ?? '';
120                 $this->image = $data['image'] ?? '';
121                 $this->url   = $data['url'] ?? '';
122                 $this->text  = $data['text'] ?? '';
123                 $this->when  = $data['when'] ?? '';
124                 $this->ago   = $data['ago'] ?? '';
125                 $this->seen  = $data['seen'] ?? false;
126         }
127
128         /**
129          * @inheritDoc
130          */
131         public function jsonSerialize()
132         {
133                 return get_object_vars($this);
134         }
135
136         /**
137          * @return array
138          */
139         public function toArray()
140         {
141                 return get_object_vars($this);
142         }
143 }