PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 2.31.0 All 254 releases
give / src / Subscriptions / DataTransferObjects / SubscriptionNoteQueryData.php

SubscriptionNoteQueryData.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Subscriptions/DataTransferObjects/SubscriptionNoteQueryData.php

68 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Subscriptions\DataTransferObjects;
4
5 use DateTime;
6 use Give\Framework\Support\Facades\DateTime\Temporal;
7 use Give\Subscriptions\Models\SubscriptionNote;
8 use Give\Subscriptions\ValueObjects\SubscriptionNoteType;
9
10 /**
11 * Class SubscriptionNoteQueryData
12 *
13 * @since 4.8.0
14 */
15 final class SubscriptionNoteQueryData
16 {
17 /**
18 * @var int
19 */
20 public $id;
21 /**
22 * @var string
23 */
24 public $content;
25 /**
26 * @var int
27 */
28 public $subscriptionId;
29 /**
30 * @var SubscriptionNoteType
31 */
32 public $type;
33 /**
34 * @var DateTime
35 */
36 public $createdAt;
37
38 /**
39 * Convert data from Subscription Note Object to Subscription Note Model
40 *
41 * @since 4.8.0
42 */
43 public static function fromObject($subscriptionNoteQueryObject): self
44 {
45 $self = new static();
46
47 $self->id = (int)$subscriptionNoteQueryObject->id;
48 $self->content = $subscriptionNoteQueryObject->content;
49 $self->subscriptionId = (int)$subscriptionNoteQueryObject->subscriptionId;
50 $self->type = $subscriptionNoteQueryObject->type ? new SubscriptionNoteType($subscriptionNoteQueryObject->type) : SubscriptionNoteType::ADMIN();
51 $self->createdAt = Temporal::toDateTime($subscriptionNoteQueryObject->createdAt);
52
53 return $self;
54 }
55
56 /**
57 * Convert DTO to Subscription Note
58 *
59 * @since 4.8.0
60 */
61 public function toSubscriptionNote(): SubscriptionNote
62 {
63 $attributes = get_object_vars($this);
64
65 return new SubscriptionNote($attributes);
66 }
67 }
68