| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Square\Legacy\Models; |
| 6 |
|
| 7 |
use stdClass; |
| 8 |
|
| 9 |
class SelectOption implements \JsonSerializable |
| 10 |
{ |
| 11 |
/** |
| 12 |
* @var string |
| 13 |
*/ |
| 14 |
private $referenceId; |
| 15 |
|
| 16 |
/** |
| 17 |
* @var string |
| 18 |
*/ |
| 19 |
private $title; |
| 20 |
|
| 21 |
/** |
| 22 |
* @param string $referenceId |
| 23 |
* @param string $title |
| 24 |
*/ |
| 25 |
public function __construct(string $referenceId, string $title) |
| 26 |
{ |
| 27 |
$this->referenceId = $referenceId; |
| 28 |
$this->title = $title; |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Returns Reference Id. |
| 33 |
* The reference id for the option. |
| 34 |
*/ |
| 35 |
public function getReferenceId(): string |
| 36 |
{ |
| 37 |
return $this->referenceId; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Sets Reference Id. |
| 42 |
* The reference id for the option. |
| 43 |
* |
| 44 |
* @required |
| 45 |
* @maps reference_id |
| 46 |
*/ |
| 47 |
public function setReferenceId(string $referenceId): void |
| 48 |
{ |
| 49 |
$this->referenceId = $referenceId; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Returns Title. |
| 54 |
* The title text that displays in the select option button. |
| 55 |
*/ |
| 56 |
public function getTitle(): string |
| 57 |
{ |
| 58 |
return $this->title; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Sets Title. |
| 63 |
* The title text that displays in the select option button. |
| 64 |
* |
| 65 |
* @required |
| 66 |
* @maps title |
| 67 |
*/ |
| 68 |
public function setTitle(string $title): void |
| 69 |
{ |
| 70 |
$this->title = $title; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Encode this object to JSON |
| 75 |
* |
| 76 |
* @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields |
| 77 |
* are set. (default: false) |
| 78 |
* |
| 79 |
* @return array|stdClass |
| 80 |
*/ |
| 81 |
#[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) |
| 82 |
public function jsonSerialize(bool $asArrayWhenEmpty = false) |
| 83 |
{ |
| 84 |
$json = []; |
| 85 |
$json['reference_id'] = $this->referenceId; |
| 86 |
$json['title'] = $this->title; |
| 87 |
$json = array_filter($json, function ($val) { |
| 88 |
return $val !== null; |
| 89 |
}); |
| 90 |
|
| 91 |
return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json; |
| 92 |
} |
| 93 |
} |
| 94 |
|