1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<?php
namespace AutomateWoo\Entity;
use AutomateWoo\Traits\NamedEntity; use AutomateWoo\Traits\OptionsEntity;
/** * NamedEntity class. * * @since 5.1.0 * @package AutomateWoo\Entity */ abstract class NamedEntityWithOptions implements ToArray {
use NamedEntity; use OptionsEntity;
/** * NamedEntityWithOptions constructor. * * @param string $name The entity name. * @param array $options Options for the entity. */ public function __construct( $name, $options = [] ) { $this->name = $name; $this->options = $options; }
/** * Convert the object's data to an array. * * @return array */ public function to_array(): array { return [ 'name' => $this->get_name() ?? '', 'options' => $this->get_options() ?? [], ]; } }
|