PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.16.0
GiveWP – Donation Plugin and Fundraising Platform v2.16.0
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 in GiveWP – Donation Plugin and Fundraising Platform 2.16.0, at src/Framework/FieldsAPI/Option.php

60 lines 834 B
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 use Concerns\HasLabel;
15
16 /** @var string */
17 protected $value;
18
19 /**
20 * @param string $value
21 * @param ?string $label
22 */
23 public function __construct( $value, $label = null ) {
24 $this->value = $value;
25 $this->label = $label;
26 }
27
28 /**
29 * Create a new option.
30 *
31 * @since 2.12.0
32 *
33 * @return static
34 */
35 public static function make( ...$args ) {
36 return new static( ...$args );
37 }
38
39 /**
40 * Access the value
41 *
42 * @since 2.12.0
43 *
44 * @return string
45 */
46 public function getValue() {
47 return $this->value;
48 }
49
50 /**
51 * {@inheritdoc}
52 */
53 public function jsonSerialize() {
54 return [
55 'value' => $this->getValue(),
56 'label' => $this->getLabel(),
57 ];
58 }
59 }
60