Url
2 days ago
ColumnFactoryDefinition.php
2 days ago
ColumnId.php
2 days ago
ColumnWidth.php
2 days ago
DateRange.php
2 days ago
EditorUrlFactory.php
2 days ago
FileSize.php
2 days ago
Group.php
2 days ago
Groups.php
2 days ago
Integration.php
2 days ago
Integrations.php
2 days ago
KeyGenerator.php
2 days ago
Labels.php
2 days ago
Link.php
2 days ago
ListScreenId.php
2 days ago
ListScreenIdGenerator.php
2 days ago
ListScreenStatus.php
2 days ago
OriginalColumn.php
2 days ago
OriginalColumns.php
2 days ago
PostTypeSlug.php
2 days ago
Promo.php
2 days ago
PromoCollection.php
2 days ago
StartingPrice.php
2 days ago
TableId.php
2 days ago
TableIdCollection.php
2 days ago
TableScreenContext.php
2 days ago
TaxonomySlug.php
2 days ago
ToggleOptions.php
2 days ago
Uri.php
2 days ago
Url.php
2 days ago
UserId.php
2 days ago
UserRole.php
2 days ago
UserRoles.php
2 days ago
Value.php
2 days ago
ValueCollection.php
2 days ago
Value.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Type; |
| 6 | |
| 7 | final class Value |
| 8 | { |
| 9 | /** |
| 10 | * @var mixed The unique identifier of the value. |
| 11 | */ |
| 12 | private $id; |
| 13 | |
| 14 | /** |
| 15 | * @var mixed The actual value. |
| 16 | */ |
| 17 | private $value; |
| 18 | |
| 19 | public function __construct($id, $value = null) |
| 20 | { |
| 21 | if (null === $value) { |
| 22 | $value = $id; |
| 23 | } |
| 24 | |
| 25 | $this->id = $id; |
| 26 | $this->value = $value; |
| 27 | } |
| 28 | |
| 29 | public function get_id() |
| 30 | { |
| 31 | return $this->id; |
| 32 | } |
| 33 | |
| 34 | public function with_value($value): self |
| 35 | { |
| 36 | return new self($this->id, $value); |
| 37 | } |
| 38 | |
| 39 | public function get_value() |
| 40 | { |
| 41 | return $this->value; |
| 42 | } |
| 43 | |
| 44 | public function __toString(): string |
| 45 | { |
| 46 | return is_scalar($this->value) |
| 47 | ? (string)$this->value |
| 48 | : ''; |
| 49 | } |
| 50 | |
| 51 | } |
| 52 |