PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Campaigns / Blocks / CampaignComments / DataTransferObjects / BlockAttributes.php

BlockAttributes.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Campaigns/Blocks/CampaignComments/DataTransferObjects/BlockAttributes.php

91 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Campaigns\Blocks\CampaignComments\DataTransferObjects;
4
5 use Give\Framework\Support\Contracts\Arrayable;
6
7 /**
8 * @since 4.0.0
9 */
10 class BlockAttributes implements Arrayable
11 {
12 /**
13 * @var string
14 */
15 public $blockId;
16
17 /**
18 * @var int
19 */
20 public $campaignId;
21
22 /**
23 * @var string
24 */
25 public $title;
26
27 /**
28 * @var bool
29 */
30 public $showAnonymous;
31
32 /**
33 * @var bool
34 */
35 public $showAvatar;
36
37 /**
38 * @var bool
39 */
40 public $showDate;
41
42 /**
43 * @var bool
44 */
45 public $showName;
46
47 /**
48 * @var int
49 */
50 public $commentLength;
51
52 /**
53 * @var string
54 */
55 public $readMoreText;
56
57 /**
58 * @var int
59 */
60 public $commentsPerPage;
61
62 /**
63 * @since 4.0.0
64 */
65 public static function fromArray(array $array): BlockAttributes
66 {
67 $self = new self();
68
69 $self->blockId = !empty($array['blockId']) ? (string)$array['blockId'] : null;
70 $self->campaignId = !empty($array['campaignId']) ? (int)$array['campaignId'] : null;
71 $self->title = !empty($array['title']) ? (string)$array['title'] : '';
72 $self->showAnonymous = !isset($array['showAnonymous']) || (bool)$array['showAnonymous'];
73 $self->showAvatar = !isset($array['showAvatar']) || (bool)$array['showAvatar'];
74 $self->showDate = !isset($array['showDate']) || (bool)$array['showDate'];
75 $self->showName = !isset($array['showName']) || (bool)$array['showName'];
76 $self->commentLength = isset($array['commentLength']) ? (int)$array['commentLength'] : 200;
77 $self->readMoreText = !empty($array['readMoreText']) ? (string)$array['readMoreText'] : '';
78 $self->commentsPerPage = isset($array['commentsPerPage']) ? (int)$array['commentsPerPage'] : 3;
79
80 return $self;
81 }
82
83 /**
84 * @since 4.0.0
85 */
86 public function toArray(): array
87 {
88 return get_object_vars($this);
89 }
90 }
91