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 / DonationForms / V2 / Properties / DonationFormLevel.php

DonationFormLevel.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonationForms/V2/Properties/DonationFormLevel.php

64 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonationForms\V2\Properties;
4
5 use Give\Framework\Support\ValueObjects\Money;
6
7 final class DonationFormLevel
8 {
9 /**
10 * @var int
11 */
12 public $id;
13 /**
14 * @var Money
15 */
16 public $amount;
17 /**
18 * @var string
19 */
20 public $label;
21 /**
22 * @var bool
23 */
24 public $isDefault;
25
26 /**
27 * @since 2.24.0
28 *
29 * @param array $array
30 *
31 * @return DonationFormLevel
32 */
33 public static function fromArray(array $array): DonationFormLevel
34 {
35 $self = new static();
36
37 $self->id = $array['_give_id']['level_id'];
38 $self->amount = Money::fromDecimal($array['_give_amount'], give_get_currency());
39 $self->label = $array['_give_text'] ?? '';
40 $self->isDefault = isset($array['_give_default']) && $array['_give_default'] === 'default';
41
42 return $self;
43 }
44
45 /**
46 * @since 2.24.0
47 *
48 * @param string $price
49 *
50 * @return DonationFormLevel
51 */
52 public static function fromPrice(string $price): DonationFormLevel
53 {
54 $self = new static();
55
56 $self->id = 0;
57 $self->amount = Money::fromDecimal($price, give_get_currency());
58 $self->label = '';
59 $self->isDefault = true;
60
61 return $self;
62 }
63 }
64