<?php

namespace SugarCalendarBookings\Support\Database\Relations;

// phpcs:ignore WPForms.PHP.UseStatement.UnusedUseStatement
use SugarCalendarBookings\Support\Database\AbstractModel;

/**
 * Has many (one-to-many) relation class.
 *
 * @since 1.0.0
 */
class HasManyRelation extends AbstractRelation {

	/**
	 * Foreign key on the related model.
	 *
	 * @since 1.0.0
	 *
	 * @var string
	 */
	protected $foreign_key;

	/**
	 * Local key on the parent model.
	 *
	 * @since 1.0.0
	 *
	 * @var string
	 */
	protected $local_key;

	/**
	 * Constructor.
	 *
	 * @since 1.0.0
	 *
	 * @param AbstractModel               $parent      Parent model instance.
	 * @param class-string<AbstractModel> $related     Related model class.
	 * @param string                      $foreign_key Foreign key.
	 * @param string                      $local_key   Local key.
	 */
	public function __construct( $parent, $related, $foreign_key, $local_key ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound

		parent::__construct( $parent, $related );

		$this->foreign_key = $foreign_key;
		$this->local_key   = $local_key;
	}

	/**
	 * Get the foreign key.
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	public function get_foreign_key() {

		return $this->foreign_key;
	}

	/**
	 * Get the local key.
	 *
	 * @since 1.0.0
	 *
	 * @return string
	 */
	public function get_local_key() {

		return $this->local_key;
	}

	/**
	 * Get the default value for the relation.
	 *
	 * @since 1.0.0
	 *
	 * @return mixed
	 */
	public function get_default_value() {

		return [];
	}
}
