26 lines
595 B
PHP
26 lines
595 B
PHP
<?php
|
|
|
|
class Post {
|
|
private $data = [];
|
|
|
|
public function __construct($post) {
|
|
$this->sanitize($post);
|
|
}
|
|
|
|
private function sanitize($post) {
|
|
foreach ($post as $key => $value) {
|
|
$this->data[$key] = is_array($value)
|
|
? filter_var_array($value, FILTER_SANITIZE_FULL_SPECIAL_CHARS)
|
|
: filter_var($value, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
|
}
|
|
}
|
|
|
|
public function get($key, $default = null) {
|
|
return $this->data[$key] ?? $default;
|
|
}
|
|
|
|
public function all() {
|
|
return $this->data;
|
|
}
|
|
}
|