<?php

namespace OxygenApp\Models;
if (!defined('ABSPATH')) exit;
class BaseModel {
    
    /**
     * Sanitize input data
     */
    protected function sanitize($data) {
        foreach ($data as $key => $value) {
            if (is_string($value)) {
                $data[$key] = sanitize_text_field(wp_unslash($value));
            } elseif (is_int($value) || is_float($value)) {
                $data[$key] = absint($value);
            } elseif (is_bool($value)) {
                $data[$key] = (int) $value;
            } elseif (is_null($value)) {
                $data[$key] = null;
            } else {
                unset($data[$key]);
            }
        }
        return $data;
    }
}