PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.33.5
GiveWP – Donation Plugin and Fundraising Platform v2.33.5
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 / Framework / FieldsAPI / Option.php
Option.php
67 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\Framework\FieldsAPI;
4
5 use JsonSerializable;
6
7 /**
8 * Class Option
9 *
10 * @since 2.12.0
11 */
12 class Option implements JsonSerializable
13 {
14
15 use Concerns\HasLabel;
16
17 /** @var string */
18 protected $value;
19
20 /**
21 * @since 2.23.1 Make constructor final to avoid unsafe usage of `new static()`.
22 *
23 * @param string $value
24 * @param ?string $label
25 */
26 final public function __construct($value, $label = null)
27 {
28 $this->value = $value;
29 $this->label = $label;
30 }
31
32 /**
33 * Create a new option.
34 *
35 * @since 2.12.0
36 *
37 * @return static
38 */
39 public static function make(...$args)
40 {
41 return new static(...$args);
42 }
43
44 /**
45 * Access the value
46 *
47 * @since 2.12.0
48 *
49 * @return string
50 */
51 public function getValue()
52 {
53 return $this->value;
54 }
55
56 /**
57 * {@inheritdoc}
58 */
59 public function jsonSerialize()
60 {
61 return [
62 'value' => $this->getValue(),
63 'label' => $this->getLabel(),
64 ];
65 }
66 }
67