| @@ -59,8 +59,17 @@ | ||
| 59 | 59 | */ |
| 60 | 60 | protected $mapping = array(); |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | + * Get the table name. | |
| 64 | + * | |
| 65 | + * @return string|null | |
| 66 | + */ | |
| 67 | + public function get_table(): ?string { | |
| 68 | + return $this->table; | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 63 | 72 | * Run the validation. |
| 64 | 73 | * |
| 65 | 74 | * @return bool |
| 66 | 75 | */ |
| @@ -224,9 +233,18 @@ | ||
| 224 | 233 | $this->import_old_way( $data ); |
| 225 | 234 | } else { |
| 226 | 235 | foreach ( array_keys( $this->annotations ) as $property ) { |
| 227 | 236 | if ( isset( $data[ $property ] ) && $this->has_property( $property ) ) { |
| 228 | - $this->$property = $data[ $property ]; | |
| 237 | + $value = $data[ $property ]; | |
| 238 | + $type = $this->annotations[ $property ]['type']; | |
| 239 | + if ( false !== $type ) { | |
| 240 | + if ( 'boolean' === $type || 'bool' === $type ) { | |
| 241 | + $value = filter_var( $value, FILTER_VALIDATE_BOOLEAN ); | |
| 242 | + } else { | |
| 243 | + settype( $value, $type ); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + $this->$property = $value; | |
| 229 | 247 | } |
| 230 | 248 | } |
| 231 | 249 | |
| 232 | 250 | $this->sanitize(); |