<?php

abstract class Abstract_rtgc_callback implements \Rtgc_callback
{

    protected $field_xss_clean = true;
    protected $crud = null;
    protected $field_name = null;
    protected array $error_msg = [];

    public function get_field_xss_clean()
    {
        return $this->field_xss_clean;
    }

    public function get_crud()
    {
        return $this->crud;
    }

    public function get_field_name()
    {
        return $this->field_name;
    }

    public function set_field_xss_clean($field_xss_clean)
    {
        $this->field_xss_clean = $field_xss_clean;
        return $this;
    }

    public function set_crud($crud)
    {
        $this->crud = $crud;
        return $this;
    }

    public function set_field_name($field_name)
    {
        $this->field_name = $field_name;
        return $this;
    }

    public function add_error($message = ''): self
    {
        $message = trim($message);
        if (!empty($message) && !in_array($message, $this->error_msg)) {
            $this->error_msg[] = $message;
        }
        return $this;
    }

    public function get_error_msg(): array
    {
        return $this->error_msg;
    }
}
