Input
1 month ago
OptionCollectionFactory
1 month ago
Type
1 month ago
Input.php
1 month ago
OptionCollection.php
1 month ago
OptionCollectionFactory.php
1 month ago
Input.php
75 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Setting\Control; |
| 6 | |
| 7 | use AC\Setting\AttributeCollection; |
| 8 | |
| 9 | class Input |
| 10 | { |
| 11 | |
| 12 | private string $name; |
| 13 | |
| 14 | private string $type; |
| 15 | |
| 16 | private $value; |
| 17 | |
| 18 | private ?string $placeholder; |
| 19 | |
| 20 | private ?AttributeCollection $attributes; |
| 21 | |
| 22 | public function __construct( |
| 23 | string $name, |
| 24 | string $type, |
| 25 | $value = null, |
| 26 | ?string $placeholder = null, |
| 27 | ?AttributeCollection $attributes = null |
| 28 | ) { |
| 29 | if ($attributes === null) { |
| 30 | $attributes = new AttributeCollection(); |
| 31 | } |
| 32 | |
| 33 | $this->name = $name; |
| 34 | $this->type = $type; |
| 35 | $this->value = $value; |
| 36 | $this->placeholder = $placeholder; |
| 37 | $this->attributes = $attributes; |
| 38 | } |
| 39 | |
| 40 | public function get_name(): string |
| 41 | { |
| 42 | return $this->name; |
| 43 | } |
| 44 | |
| 45 | public function get_type(): string |
| 46 | { |
| 47 | return $this->type; |
| 48 | } |
| 49 | |
| 50 | public function has_value(): bool |
| 51 | { |
| 52 | return $this->value !== null; |
| 53 | } |
| 54 | |
| 55 | public function get_value() |
| 56 | { |
| 57 | return $this->value; |
| 58 | } |
| 59 | |
| 60 | public function has_placeholder(): bool |
| 61 | { |
| 62 | return $this->placeholder !== null; |
| 63 | } |
| 64 | |
| 65 | public function get_placeholder(): ?string |
| 66 | { |
| 67 | return $this->placeholder; |
| 68 | } |
| 69 | |
| 70 | public function get_attributes(): AttributeCollection |
| 71 | { |
| 72 | return $this->attributes; |
| 73 | } |
| 74 | |
| 75 | } |