<?php

namespace SugarCalendarBookings\Support\Database;

/**
 * Meta model for storing key-value pairs for other models.
 *
 * @since 1.0.0
 *
 * @property int    $id
 * @property string $object_type
 * @property int    $object_id
 * @property string $meta_key
 * @property mixed  $meta_value
 */
class MetaModel extends AbstractModel {

	/**
	 * The database table name without prefix.
	 *
	 * @since 1.0.0
	 *
	 * @var string
	 */
	protected static $table_name = 'meta';

	/**
	 * The model type identifier.
	 *
	 * @since 1.0.0
	 *
	 * @var string
	 */
	protected static $type = 'meta';

	/**
	 * Column formats for the model.
	 *
	 * @since 1.0.0
	 *
	 * @var array<string, string>
	 */
	protected static $column_formats = [
		'id'          => '%d',
		'object_type' => '%s',
		'object_id'   => '%d',
		'meta_key'    => '%s', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Column format definition, not a query.
		'meta_value'  => '%s', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- Column format definition, not a query.
	];

	/**
	 * The attributes and meta that should be cast.
	 *
	 * @since 1.0.0
	 *
	 * @var array<string, string>
	 */
	protected static $casts = [
		'id'        => 'integer',
		'object_id' => 'integer',
	];
}
