12345678910111213141516 |
- <?php
- namespace DNB;
- abstract class AbstractPostSerializable implements PostSerializableInterface {
- public static function fromPostParams(array $post): PostSerializableInterface {
- $vars = [];
- foreach (static::getClassVars() as $key)
- $vars[$key] = isset($post[$key]) && ((bool)$post[$key]) && strtolower((string)$post[$key]) != "off" ? htmlspecialchars($post[$key], ENT_QUOTES | ENT_SUBSTITUTE) : null;
- return new static(...$vars);
- }
- abstract protected static function getClassVars(): array;
- }
|