Total Complexity | 8 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class DBCreateTable |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * Private variable to store the name of the field to create |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | private $data; |
||
21 | |||
22 | /** |
||
23 | * Constructor |
||
24 | * |
||
25 | * @param string $field |
||
26 | * @param string $datatype |
||
27 | */ |
||
28 | 1 | public function __construct(string $field, string $datatype) |
|
29 | { |
||
30 | 1 | $this->data['field'] = $field; |
|
31 | 1 | $this->data['datatype'] = $datatype; |
|
32 | 1 | } |
|
33 | |||
34 | /** |
||
35 | * Magic setter method |
||
36 | * |
||
37 | * @param string $name |
||
38 | * @param string|int|null $value |
||
39 | */ |
||
40 | 1 | public function __set(string $name, $value): DBCreateTable |
|
41 | { |
||
42 | 1 | if (in_array($name, ['field', 'datatype', 'default', 'option'])) { |
|
43 | 1 | $this->data[$name] = $value; |
|
44 | } |
||
45 | |||
46 | 1 | return $this; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Magic method to convert the class to a string |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | 1 | public function __toString(): string |
|
60 | } |
||
61 | } |
||
62 |