| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Entity\EntryField; |
| 4 |
|
| 5 |
// phpcs:disable PSR1.Files.SideEffects |
| 6 |
if (!defined('ABSPATH')) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
use IvyForms\ValueObjects\Entry\EntryField as EntryFieldValueObject; |
| 11 |
|
| 12 |
/** |
| 13 |
* Class EntryField |
| 14 |
* |
| 15 |
* @package IvyForms\Entity\Entry |
| 16 |
*/ |
| 17 |
class EntryField |
| 18 |
{ |
| 19 |
/** |
| 20 |
* @var EntryFieldValueObject |
| 21 |
*/ |
| 22 |
private EntryFieldValueObject $field; |
| 23 |
|
| 24 |
/** |
| 25 |
* EntryField constructor. |
| 26 |
* |
| 27 |
* @param EntryFieldValueObject $field The entry field value object. |
| 28 |
*/ |
| 29 |
public function __construct(EntryFieldValueObject $field) |
| 30 |
{ |
| 31 |
$this->field = $field; |
| 32 |
} |
| 33 |
|
| 34 |
public function getId(): ?int |
| 35 |
{ |
| 36 |
return $this->field->id; |
| 37 |
} |
| 38 |
public function setId(int $id): void |
| 39 |
{ |
| 40 |
$this->field->id = $id; |
| 41 |
} |
| 42 |
|
| 43 |
public function getFieldId(): int |
| 44 |
{ |
| 45 |
return $this->field->fieldId; |
| 46 |
} |
| 47 |
public function setFieldId(int $fieldId): void |
| 48 |
{ |
| 49 |
$this->field->fieldId = $fieldId; |
| 50 |
} |
| 51 |
|
| 52 |
public function getFieldValue(): string |
| 53 |
{ |
| 54 |
return $this->field->fieldValue; |
| 55 |
} |
| 56 |
public function setFieldValue(string $fieldValue): void |
| 57 |
{ |
| 58 |
$this->field->fieldValue = $fieldValue; |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
public function getField(): EntryFieldValueObject |
| 63 |
{ |
| 64 |
return $this->field; |
| 65 |
} |
| 66 |
/** |
| 67 |
* Get the entry ID associated with the entry field. |
| 68 |
* |
| 69 |
* @return int|null The entry ID or null if not set. |
| 70 |
*/ |
| 71 |
|
| 72 |
public function getEntryId(): ?int |
| 73 |
{ |
| 74 |
return $this->field->entryId; |
| 75 |
} |
| 76 |
/** |
| 77 |
* Set the entry ID associated with the entry field. |
| 78 |
* |
| 79 |
* @param int|null $entryId The entry ID to set. |
| 80 |
*/ |
| 81 |
public function setEntryId(?int $entryId): void |
| 82 |
{ |
| 83 |
$this->field->entryId = $entryId; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Convert the entry field to an array representation. |
| 88 |
* |
| 89 |
* @return array<mixed> The array representation of the entry field. |
| 90 |
*/ |
| 91 |
public function toArray(): array |
| 92 |
{ |
| 93 |
return $this->field->toArray(); |
| 94 |
} |
| 95 |
} |
| 96 |
|