PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 / Rules / Concerns / HasExemptAmounts.php

HasExemptAmounts.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/DonationForms/Rules/Concerns/HasExemptAmounts.php

54 lines 1.1 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\Rules\Concerns;
4
5 use function in_array;
6 use function is_numeric;
7
8 /**
9 * Amounts an admin configured on the donation amount block, such as the donation levels or the fixed set
10 * price. The custom amount minimum and maximum only constrain what a donor types into the custom amount
11 * input, so those amounts are always accepted.
12 *
13 * @since 4.16.8
14 */
15 trait HasExemptAmounts
16 {
17 /**
18 * @since 4.16.8
19 *
20 * @var float[]
21 */
22 protected $exemptAmounts = [];
23
24 /**
25 * @since 4.16.8
26 */
27 public function exemptAmounts(float ...$amounts): self
28 {
29 $this->exemptAmounts = $amounts;
30
31 return $this;
32 }
33
34 /**
35 * @since 4.16.8
36 *
37 * @return float[]
38 */
39 public function getExemptAmounts(): array
40 {
41 return $this->exemptAmounts;
42 }
43
44 /**
45 * @since 4.16.8
46 *
47 * @param mixed $value
48 */
49 protected function isExemptAmount($value): bool
50 {
51 return is_numeric($value) && in_array((float)$value, $this->exemptAmounts, true);
52 }
53 }
54