PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.19.6
GiveWP – Donation Plugin and Fundraising Platform v2.19.6
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 2.31.1 All 253 releases
give / src / Donors / DataTransferObjects / DonorQueryData.php
DonorQueryData.php
84 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Donors\DataTransferObjects;
4
5 use Give\Donors\Models\Donor;
6 use Give\Framework\Support\Facades\DateTime\Temporal;
7
8 /**
9 * Class DonorObjectData
10 *
11 * @since 2.19.6
12 */
13 class DonorQueryData
14 {
15
16 /**
17 * @var int
18 */
19 public $id;
20 /**
21 * @var string
22 */
23 public $createdAt;
24 /**
25 * @var int
26 */
27 public $userId;
28 /**
29 * @var string
30 */
31 public $email;
32 /**
33 * @var string
34 */
35 public $name;
36 /**
37 * @var string
38 */
39 public $firstName;
40 /**
41 * @var string
42 */
43 public $lastName;
44 /**
45 * @var mixed
46 */
47 public $additionalEmails;
48
49 /**
50 * Convert data from donor object to Donor Model
51 *
52 * @since 2.19.6
53 *
54 * @return self
55 */
56 public static function fromObject($object)
57 {
58 $self = new static();
59
60 $self->id = (int)$object->id;
61 $self->userId = (int)$object->userId;
62 $self->email = $object->email;
63 $self->name = $object->name;
64 $self->firstName = $object->firstName;
65 $self->lastName = $object->lastName;
66 $self->createdAt = Temporal::toDateTime($object->createdAt);
67 $self->additionalEmails = json_decode($object->additionalEmails, true);
68
69 return $self;
70 }
71
72 /**
73 * Convert DTO to Donation
74 *
75 * @return Donor
76 */
77 public function toDonor()
78 {
79 $attributes = get_object_vars($this);
80
81 return new Donor($attributes);
82 }
83 }
84