-
Notifications
You must be signed in to change notification settings - Fork 0
/
Link.php
2660 lines (2432 loc) · 71.5 KB
/
Link.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
declare(strict_types=1);
namespace snuze\Reddit\Thing;
/**
* The Link class represents the significant properties of a link, otherwise
* known as a submission, post, or thread. An attempt has been made to map all
* fields supplied by the API, regardless of their utility (or lack thereof).
*
* Implementation warning: Array properties are currently populated as-is,
* without any further processing. Calling their getters will return an array
* holding key/value pairs defining the property. This is subject to change in a
* future major version, such that some other value(s) may be returned instead.
*
* *****************************************************************************
* This file is part of Snuze, a PHP client for the Reddit API.
* Copyright 2019 Shaun Cummiskey <shaun@shaunc.com> <https://shaunc.com/>
* Repository: <https://github.com/snuze/snuze/>
* Documentation: <https://snuze.shaunc.com/>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class Link extends Thing
{
/*
* These properties are documented alongside their accessors, below.
*/
protected $allAwardings = [];
protected $allowLiveComments = true;
protected $approved = null; //bool
protected $approvedAtUtc = null;
protected $approvedBy = null;
protected $archived = false;
protected $author = '';
protected $authorCakeday = null; //bool if set
protected $authorFlairBackgroundColor = null;
protected $authorFlairCssClass = null;
protected $authorFlairRichtext = [];
protected $authorFlairTemplateId = null;
protected $authorFlairText = null;
protected $authorFlairTextColor = null;
protected $authorFlairType = '';
protected $authorFullname = '';
protected $authorPatreonFlair = false;
protected $bannedAtUtc = null; //float if set
protected $bannedBy = null;
protected $canGild = true;
protected $canModPost = false;
protected $category = null;
protected $clicked = false;
protected $collections = null; //array if set; see json-samples/link-with-collection.json
protected $contentCategories = null; //array if set
protected $contestMode = false;
protected $crosspostParent = null; //string if set
protected $crosspostParentList = null; //array if set
protected $discussionType = null;
protected $distinguished = '';
protected $domain = '';
protected $downs = 0;
protected $edited = false; //float
protected $eventEnd = null; //float
protected $eventIsLive = null; //bool
protected $eventStart = null; //float
protected $gilded = 0;
protected $gildings = [];
protected $hidden = false;
protected $hideScore = false;
protected $ignoreReports = null;
protected $isCrosspostable = true;
protected $isMeta = false;
protected $isOriginalContent = false;
protected $isRedditMediaDomain = false;
protected $isRobotIndexable = true;
protected $isSelf = false;
protected $isVideo = false;
protected $likes = null;
protected $linkFlairBackgroundColor = '';
protected $linkFlairCssClass = null;
protected $linkFlairRichtext = [];
protected $linkFlairTemplateId = null; //string if set
protected $linkFlairText = '';
protected $linkFlairTextColor = '';
protected $linkFlairType = '';
protected $locked = false;
protected $media = null; //array if set
protected $mediaEmbed = [];
protected $mediaMetadata = null; //array if set
protected $mediaOnly = false;
protected $modNote = null;
protected $modReasonBy = null;
protected $modReasonTitle = null;
protected $modReports = [];
protected $name = '';
protected $noFollow = false;
protected $numComments = 0;
protected $numCrossposts = 0;
protected $numReports = null;
protected $over18 = false;
protected $parentWhitelistStatus = ''; //advertising whitelist
protected $permalink = '';
protected $pinned = false;
protected $postHint = '';
protected $preview = [];
protected $pwls = 0;
protected $quarantine = false;
protected $removalReason = null;
protected $removed = null; //bool
protected $reportReasons = null;
protected $rteMode = null; //string
protected $saved = false;
protected $score = 0;
protected $secureMedia = null;
protected $secureMediaEmbed = [];
protected $selftext = '';
protected $selftextHtml = '';
protected $sendReplies = false;
protected $spam = null;
protected $spoiler = false;
protected $stewardReports = [];
protected $stickied = false;
protected $subreddit = '';
protected $subredditId = '';
protected $subredditNamePrefixed = '';
protected $subredditSubscribers = 0;
protected $subredditType = '';
protected $suggestedSort = null;
protected $thumbnail = '';
protected $thumbnailHeight = null;
protected $thumbnailWidth = null;
protected $title = '';
protected $totalAwardsReceived = 0;
protected $ups = 0;
protected $url = '';
protected $userReports = [];
protected $viewCount = null; //int
protected $visited = false;
protected $whitelistStatus = ''; //advertising whitelist
protected $wls = 0;
/**
* Constructor.
*/
public function __construct() {
/* All Thing children must call parent ctor and set property names */
parent::__construct(Thing::KIND_LINK);
$this->_propertyNames = array_keys(get_object_vars($this));
$this->debug('ctor args: ' . var_export(func_get_args(), true));
}
/**
* Get an array defining the type and quantity of all awards (gold, silver,
* platinum...) this link has received.
*
* @return array
*/
public function getAllAwardings(): array {
return $this->allAwardings;
}
/**
* Set the array defining the type and quantity of all awards (gold, silver,
* platinum...) this link has received.
*
* @param array $allAwardings
* @return $this
*/
protected function setAllAwardings(array $allAwardings) {
$this->allAwardings = $allAwardings;
return $this;
}
/**
* Get whether or not comments on this link can be sorted by "live," which
* is an experimental feature.
*
* @return bool
*/
public function getAllowLiveComments(): bool {
return $this->allowLiveComments;
}
/**
* Set whether or not comments on this link can be sorted by "live," which
* is an experimental feature.
*
* @param bool $allowLiveComments
* @return $this
*/
protected function setAllowLiveComments(bool $allowLiveComments) {
$this->allowLiveComments = $allowLiveComments;
return $this;
}
/**
* Get whether or not this link was manually approved by a moderator.
*
* This is a moderator-only property. To receive an accurate value, the
* currently authenticated user must be a moderator of the subreddit where
* this link is posted.
*
* @return bool|null
*/
public function getApproved(): ?bool {
return $this->approved;
}
/**
* Set whether or not this link was manually approved by a moderator.
*
* @param bool $approved
* @return $this
*/
public function setApproved(bool $approved = null) {
$this->approved = $approved;
return $this;
}
/**
* If this link was manually approved by a moderator, get the unix epoch at
* which that occurred, else null.
*
* This is a moderator-only property. To receive an accurate value, the
* currently authenticated user must be a moderator of the subreddit where
* this link is posted.
*
* @return float|null
*/
public function getApprovedAtUtc(): ?float {
return $this->approvedAtUtc;
}
/**
* Set the epoch timestamp at which this link was manually approved by a
* moderator, if that occurred.
*
* @param float $approvedAtUtc
* @return $this
*/
protected function setApprovedAtUtc(float $approvedAtUtc = null) {
$this->approvedAtUtc = $approvedAtUtc;
return $this;
}
/**
* If this link was approved by a moderator, get the username of the mod
* who approved it, else null.
*
* This is a moderator-only property. To receive an accurate value, the
* currently authenticated user must be a moderator of the subreddit where
* this link is posted.
*
* @return string|null
*/
public function getApprovedBy(): ?string {
return $this->approvedBy;
}
/**
* Set the username of the moderator who manually approved this link, or
* null if it wasn't.
*
* @param string $approvedBy
* @return $this
*/
protected function setApprovedBy(string $approvedBy = null) {
$this->approvedBy = $approvedBy;
return $this;
}
/**
* Get whether or not this link is archived and can no longer be voted or
* commented on.
*
* @return bool
*/
public function getArchived(): bool {
return $this->archived;
}
/**
* Set whether or not this link is archived and can no longer be voted or
* commented on.
*
* @param bool $archived
* @return $this
*/
protected function setArchived(bool $archived) {
$this->archived = $archived;
return $this;
}
/**
* Get the username of the Reddit account that submitted this link.
*
* @return string
*/
public function getAuthor(): string {
return $this->author;
}
/**
* Set the username of the Reddit account that submitted this link.
*
* @param string $author
* @return $this
*/
protected function setAuthor(string $author) {
$this->author = $author;
return $this;
}
/**
* Get whether or not the "cake day" flair should decorate this link to
* celebrate its author's Reddit birthday.
*
* This property is transient and will only be true if the link is fetched
* during the duration of its author's cake day.
*
* @return bool|null
*/
public function getAuthorCakeday(): ?bool {
return $this->authorCakeday;
}
/**
* Set whether or not the "cake day" flair should decorate this link to
* celebrate its author's Reddit birthday.
*
* @param bool $authorCakeday
* @return $this
*/
protected function setAuthorCakeday(bool $authorCakeday = null) {
$this->authorCakeday = $authorCakeday;
return $this;
}
/**
* Get the HTML hex color code for the author's user flair background, if
* any. The literal string "transparent" has also been observed in this
* property.
*
* @return string|null
*/
public function getAuthorFlairBackgroundColor(): ?string {
return $this->authorFlairBackgroundColor;
}
/**
* Set the HTML hex color code for the author's user flair background, if any
*
* @param string $authorFlairBackgroundColor
* @return $this
*/
protected function setAuthorFlairBackgroundColor(string $authorFlairBackgroundColor
= null) {
$this->authorFlairBackgroundColor = $authorFlairBackgroundColor;
return $this;
}
/**
* Get the CSS class corresponding to the author's user flair, if any
*
* @return string|null
*/
public function getAuthorFlairCssClass(): ?string {
return $this->authorFlairCssClass;
}
/**
* Set the CSS class corresponding to the author's user flair, if any
*
* @param string $authorFlairCssClass
* @return $this
*/
protected function setAuthorFlairCssClass(string $authorFlairCssClass = null) {
$this->authorFlairCssClass = $authorFlairCssClass;
return $this;
}
/**
* Get the array containing the elements that define the author's user flair,
* if any.
*
* @return array
*/
public function getAuthorFlairRichtext(): array {
return $this->authorFlairRichtext;
}
/**
* Set the array containing the elements that define the author's user flair,
* if any.
*
* @param array $authorFlairRichtext
* @return $this
*/
protected function setAuthorFlairRichtext(array $authorFlairRichtext) {
$this->authorFlairRichtext = $authorFlairRichtext;
return $this;
}
/**
* Get the 36-character UUID of the author's user flair template, if any
*
* @return string|null
*/
public function getAuthorFlairTemplateId(): ?string {
return $this->authorFlairTemplateId;
}
/**
* Set the 36-character UUID of the author's user flair template, if any
*
* @param string $authorFlairTemplateId
* @return $this
*/
protected function setAuthorFlairTemplateId(string $authorFlairTemplateId = null) {
$this->authorFlairTemplateId = $authorFlairTemplateId;
return $this;
}
/**
* Get the author's user flair text, if any
*
* @return string|null
*/
public function getAuthorFlairText(): ?string {
return $this->authorFlairText;
}
/**
* Set the author's user flair text, if any
*
* @param string $authorFlairText
* @return $this
*/
protected function setAuthorFlairText(string $authorFlairText = null) {
$this->authorFlairText = $authorFlairText;
return $this;
}
/**
* Get the color, either "dark" or "light", of the author's user flair text,
* if any
*
* @return string|null
*/
public function getAuthorFlairTextColor(): ?string {
return $this->authorFlairTextColor;
}
/**
* Set the color, either "dark" or "light", of the author's user flair text,
* if any
*
* @param string $authorFlairTextColor
* @return $this
*/
protected function setAuthorFlairTextColor(string $authorFlairTextColor = null) {
$this->authorFlairTextColor = $authorFlairTextColor;
return $this;
}
/**
* Get the author's user flair type, if any; e.g. "text" or "richtext"
*
* @return string
*/
public function getAuthorFlairType(): string {
return $this->authorFlairType;
}
/**
* Set the author's user flair type, if any; e.g. "text" or "richtext"
*
* @param string $authorFlairType
* @return $this
*/
protected function setAuthorFlairType(string $authorFlairType) {
$this->authorFlairType = $authorFlairType;
return $this;
}
/**
* Get the Reddit internal "thing" fullname of the author, e.g. "t2_bva6"
*
* @return string
*/
public function getAuthorFullname(): string {
return $this->authorFullname;
}
/**
* Set the Reddit internal "thing" fullname of the author, e.g. "t2_bva6"
*
* @param string $authorFullname
* @return $this
*/
protected function setAuthorFullname(string $authorFullname) {
$this->authorFullname = $authorFullname;
return $this;
}
/**
* Get whether or not the author is a patron (via Patreon) of the subreddit
* where this link is posted, granting them special flair
*
* @return bool
*/
public function getAuthorPatreonFlair(): bool {
return $this->authorPatreonFlair;
}
/**
* Set whether or not the author is a patron (via Patreon) of the subreddit
* where this link is posted, granting them special flair
*
* @param bool $authorPatreonFlair
* @return $this
*/
protected function setAuthorPatreonFlair(bool $authorPatreonFlair) {
$this->authorPatreonFlair = $authorPatreonFlair;
return $this;
}
/**
* If this link was removed by a moderator, get the unix epoch at which
* this occurred, else null.
*
* This is a moderator-only property. To receive an accurate value, the
* currently authenticated user must be a moderator of the subreddit where
* this link is posted.
*
* @return int|null
*/
public function getBannedAtUtc(): ?int {
return $this->bannedAtUtc;
}
/**
* Set the unix epoch at which this post was removed by a moderator, if
* that occurred.
*
* @param int $bannedAtUtc
* @return $this
*/
protected function setBannedAtUtc(int $bannedAtUtc = null) {
$this->bannedAtUtc = $bannedAtUtc;
return $this;
}
/**
* If this link was removed by a moderator, get the username of the mod
* who removed it. If this link was removed by the system (e.g. flagged
* as spam) but that decision hasn't been confirmed by a moderator, returns
* the literal string '[auto]'. If the link has not been removed either way,
* returns null.
*
* This is a mutant field. When a link is removed by a human moderator,
* Reddit sends that mod's username. When a link is removed by the system,
* e.g. flagged as spam, Reddit sends boolean true. I had to settle on one
* datatype, so I went with a string and picked the '[auto]' value to
* distinguish unconfirmed automated removals.
*
* This is a moderator-only property. To receive an accurate value, the
* currently authenticated user must be a moderator of the subreddit where
* this link is posted.
*
* @return string|null
*/
public function getBannedBy(): ?string {
if ($this->bannedBy === true) {
return '[auto]';
}
return $this->bannedBy;
}
/**
* Set the username of the moderator who removed this link, if that occurred,
* or the literal string '[auto]' if the link was removed by the system
*
* @param mixed $bannedBy
* @return $this
*/
protected function setBannedBy($bannedBy = null) {
if ($bannedBy === true) {
/* Automatic system removal e.g. spam */
$bannedBy = '[auto]';
}
$this->bannedBy = $bannedBy;
return $this;
}
/**
* Get whether or not the link is eligible for gilding by the currently
* authenticated user. (You can't gild your own links.)
*
* @return bool
*/
public function getCanGild(): bool {
return $this->canGild;
}
/**
* Set whether or not the link is eligible for gilding by the currently
* authenticated user. (You can't gild your own links.)
*
* @param bool $canGild
* @return $this
*/
protected function setCanGild(bool $canGild) {
$this->canGild = $canGild;
return $this;
}
/**
* Get whether or not the currently authenticated user is permitted to
* moderate this link.
*
* @return bool
*/
public function getCanModPost(): bool {
return $this->canModPost;
}
/**
* Set whether or not the currently authenticated user is permitted to
* moderate this link.
*
* @param bool $canModPost
* @return $this
*/
protected function setCanModPost(bool $canModPost) {
$this->canModPost = $canModPost;
return $this;
}
/**
* Get the category name, if any, assigned to this link.
*
* @return string|null
*/
public function getCategory(): ?string {
return $this->category;
}
/**
* Set the category name, if any, assigned to this link.
*
* @param string $category
* @return $this
*/
protected function setCategory(string $category = null) {
$this->category = $category;
return $this;
}
/**
* Get whether or not the currently authenticated user has opened this
* link, if the user has the "Remember what links you've visited across
* computers" preference enabled (?) Not entirely sure on this.
*
* @return bool
* @todo verify what exactly this corresponds to
*/
public function getClicked(): bool {
return $this->clicked;
}
/**
* Set whether or not the currently authenticated user has opened this
* link, if the user has the "Remember what links you've visited across
* computers" preference enabled (?) Not entirely sure on this.
*
* @param bool $clicked
* @return $this
* @todo verify what exactly this corresponds to
*/
protected function setClicked(bool $clicked) {
$this->clicked = $clicked;
return $this;
}
/**
* If this link is a collection, get the array that defines the other links
* in the collection, else null
*
* @return array|null
*/
public function getCollections(): ?array {
return $this->collections;
}
/**
* If this link is a collection, set the array that defines the other links
* in the collection
*
* @param array $collections
* @return $this
*/
protected function setCollections(array $collections = null) {
$this->collections = $collections;
return $this;
}
/**
* Get an array that defines this link's content categories, if any are
* assigned
*
* @return array|null
*/
public function getContentCategories(): ?array {
return $this->contentCategories;
}
/**
* Set an array that defines this link's content categories, if any are
* assigned
*
* @param array $contentCategories
* @return $this
*/
protected function setContentCategories(array $contentCategories = null) {
$this->contentCategories = $contentCategories;
return $this;
}
/**
* Get whether or not this link has been designated as being in contest mode
* for purposes of comment display
*
* @return bool
*/
public function getContestMode(): bool {
return $this->contestMode;
}
/**
* Set whether or not this link has been designated as being in contest mode
* for purposes of comment display
*
* @param bool $contestMode
* @return $this
*/
protected function setContestMode(bool $contestMode) {
$this->contestMode = $contestMode;
return $this;
}
/**
* If this link is a crosspost, get the Reddit internal fullname of the
* original link e.g. "t3_clcb1h", else null
*
* @return string|null
*/
public function getCrosspostParent(): ?string {
return $this->crosspostParent;
}
/**
* If this link is a crosspost, set the Reddit internal fullname of the
* original link
*
* @param string $crosspostParent
* @return $this
*/
protected function setCrosspostParent(string $crosspostParent = null) {
$this->crosspostParent = $crosspostParent;
return $this;
}
/**
* If this link is a crosspost, get an array defining the significant
* properties of the original link, else null
*
* @return array|null
*/
public function getCrosspostParentList(): ?array {
return $this->crosspostParentList;
}
/**
* If this link is a crosspost, set an array defining the significant
* properties of the original link
*
* @param array $crosspostParentList
* @return $this
*/
protected function setCrosspostParentList(array $crosspostParentList = null) {
$this->crosspostParentList = $crosspostParentList;
return $this;
}
/**
* Get the discussion type for this link's comment thread, if any. If
* the link was created as a chat post (e.g. "t3_cmhugu"), this will be
* set to "CHAT"
*
* @return string|null
*/
public function getDiscussionType(): ?string {
return $this->discussionType;
}
/**
* Set the discussion type for this link's comment thread, if any
*
* @param string $discussionType
* @return $this
*/
protected function setDiscussionType(string $discussionType = null) {
$this->discussionType = $discussionType;
return $this;
}
/**
* Get the type of distinguishment set on this link (e.g. 'moderator',
* 'admin', 'special'), if any
*
* @return string
*/
public function getDistinguished(): string {
return $this->distinguished;
}
/**
* Set the type of distinguishment set on this link (e.g. 'moderator',
* 'admin', 'special'), if any
*
* @param string $distinguished
* @return $this
*/
protected function setDistinguished(string $distinguished) {
$this->distinguished = $distinguished;
return $this;
}
/**
* Get the domain this link points to. For text-only self posts, this
* will be the string 'self.' followed by the subreddit name.
*
* @return string
*/
public function getDomain(): string {
return $this->domain;
}
/**
* Set the domain this link points to. For text-only self posts, this
* will be the string 'self.' followed by the subreddit name.
*
* @param string $domain
* @return $this
*/
protected function setDomain(string $domain) {
$this->domain = $domain;
return $this;
}
/**
* Get the number of downvotes that have been recorded on this link. This
* is generally not provided by the API; instead, refer to "ups" and "score"
*
* @return int
* @see getScore()
* @see getUps()
*/
public function getDowns(): int {
return $this->downs;
}
/**
* Set the number of downvotes that have been recorded on this link
*
* @param int $downs
* @return $this
*/
protected function setDowns(int $downs) {
$this->downs = $downs;
return $this;
}
/**
* Get the unix epoch timestamp at which this link was edited, or 0.0 if it
* hasn't been edited.
*
* This is a mutant field. If a link has been edited, Reddit returns the
* epoch timestamp as a float. If it hasn't been edited, Reddit returns
* boolean false. I had to settle on one datatype, so float it is.
*
* @return float
*/
public function getEdited(): float {
if ($this->edited === false) {
return 0.0;
}
return $this->edited;
}
/**
* Set the unix epoch timestamp at which this link was edited, or 0.0 if it
* hasn't been edited.
*
* This is a mutant field. If a link has been edited, Reddit returns the
* epoch timestamp as a float. If it hasn't been edited, Reddit returns
* boolean false. I had to settle on one datatype, so float it is.
*
* @param type $edited
* @return $this
*/
protected function setEdited($edited) {
$this->edited = (float) $edited;
return $this;
}
/**
* If this link is marked as an event, get the unix epoch at which the
* event is scheduled to end, else null
*
* @return float|null
*/
public function getEventEnd(): ?float {
return $this->eventEnd;
}
/**
* If this link is marked as an event, set the unix epoch at which the
* event is scheduled to end, else null
*
* @param float $eventEnd
* @return $this
*/
public function setEventEnd(float $eventEnd = null) {
$this->eventEnd = $eventEnd;
return $this;
}
/**
* If this link is marked as an event, get whether or not it's currently
* active at the time the link was fetched
*
* @return bool|null
*/
public function getEventIsLive(): ?bool {
return $this->eventIsLive;
}
/**
* If this link is marked as an event, set whether or not it's currently
* active at the time the link was fetched
*
* @param bool $eventIsLive
* @return $this
*/
public function setEventIsLive(bool $eventIsLive = null) {
$this->eventIsLive = $eventIsLive;
return $this;
}
/**
* If this link is marked as an event, get the unix epoch at which the
* event is scheduled to begin, else null
*
* @return float|null
*/
public function getEventStart(): ?float {
return $this->eventStart;
}
/**
* If this link is marked as an event, set the unix epoch at which the
* event is scheduled to begin, else null
*
* @param float $eventStart
* @return $this
*/
public function setEventStart(float $eventStart = null) {
$this->eventStart = $eventStart;
return $this;
}
/**
* Get the number of times this link has been gilded
*
* @return int
*/
public function getGilded(): int {