Cart.php
7 months ago
ContactList.php
11 months ago
Form.php
9 months ago
Model.php
11 months ago
PluginData.php
8 months ago
ContactList.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Hostinger\Reach\Models; |
| 4 | |
| 5 | if ( ! defined( 'ABSPATH' ) ) { |
| 6 | die; |
| 7 | } |
| 8 | |
| 9 | class ContactList implements Model { |
| 10 | private int $id = 0; |
| 11 | private string $name; |
| 12 | |
| 13 | |
| 14 | public function __construct( array $db_array = array() ) { |
| 15 | if ( isset( $db_array['id'] ) ) { |
| 16 | $this->set_id( $db_array['id'] ); |
| 17 | } |
| 18 | |
| 19 | if ( isset( $db_array['name'] ) ) { |
| 20 | $this->set_name( $db_array['name'] ); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | public function get_id(): int { |
| 25 | return $this->id; |
| 26 | } |
| 27 | |
| 28 | public function set_id( int $id ): void { |
| 29 | $this->id = $id; |
| 30 | } |
| 31 | |
| 32 | public function get_name(): string { |
| 33 | return $this->name; |
| 34 | } |
| 35 | |
| 36 | public function set_name( string $name ): void { |
| 37 | $this->name = sanitize_text_field( trim( $name ) ); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | public function to_array(): array { |
| 42 | return array( |
| 43 | 'id' => $this->get_id(), |
| 44 | 'name' => $this->get_name(), |
| 45 | ); |
| 46 | } |
| 47 | } |
| 48 |