]> git.mxchange.org Git - friendica.git/blob - src/Object/Notification/Notification.php
Merge pull request #8170 from nupplaphil/task/repo_notification
[friendica.git] / src / Object / Notification / Notification.php
1 <?php
2
3 namespace Friendica\Object\Notification;
4
5 /**
6  * A view-only object for printing item notifications to the frontend
7  */
8 class Notification implements \JsonSerializable
9 {
10         const SYSTEM   = 'system';
11         const PERSONAL = 'personal';
12         const NETWORK  = 'network';
13         const INTRO    = 'intro';
14         const HOME     = 'home';
15
16         /** @var string */
17         private $label = '';
18         /** @var string */
19         private $link = '';
20         /** @var string */
21         private $image = '';
22         /** @var string */
23         private $url = '';
24         /** @var string */
25         private $text = '';
26         /** @var string */
27         private $when = '';
28         /** @var string */
29         private $ago = '';
30         /** @var boolean */
31         private $seen = false;
32
33         /**
34          * @return string
35          */
36         public function getLabel()
37         {
38                 return $this->label;
39         }
40
41         /**
42          * @return string
43          */
44         public function getLink()
45         {
46                 return $this->link;
47         }
48
49         /**
50          * @return string
51          */
52         public function getImage()
53         {
54                 return $this->image;
55         }
56
57         /**
58          * @return string
59          */
60         public function getUrl()
61         {
62                 return $this->url;
63         }
64
65         /**
66          * @return string
67          */
68         public function getText()
69         {
70                 return $this->text;
71         }
72
73         /**
74          * @return string
75          */
76         public function getWhen()
77         {
78                 return $this->when;
79         }
80
81         /**
82          * @return string
83          */
84         public function getAgo()
85         {
86                 return $this->ago;
87         }
88
89         /**
90          * @return bool
91          */
92         public function isSeen()
93         {
94                 return $this->seen;
95         }
96
97         public function __construct(array $data)
98         {
99                 $this->label = $data['label'] ?? '';
100                 $this->link  = $data['link'] ?? '';
101                 $this->image = $data['image'] ?? '';
102                 $this->url   = $data['url'] ?? '';
103                 $this->text  = $data['text'] ?? '';
104                 $this->when  = $data['when'] ?? '';
105                 $this->ago   = $data['ago'] ?? '';
106                 $this->seen  = $data['seen'] ?? false;
107         }
108
109         /**
110          * @inheritDoc
111          */
112         public function jsonSerialize()
113         {
114                 return get_object_vars($this);
115         }
116
117         /**
118          * @return array
119          */
120         public function toArray()
121         {
122                 return get_object_vars($this);
123         }
124 }