<?php
declare(strict_types=1);

namespace AuxCF\Entities\Traits;

use AuxCF\Entities\FieldsCollectionEntity;

/**
 * Functionality for managing a FieldsCollectionEntity instance.
 * The FieldsCollectionEntity is a collection of fields that can be used in multiple field groups.
 * This trait can be used by any class that needs to store and access a collection
 * of fields. It provides getter and setter methods.
 *
 * @package AuxCF\Entities\Traits
 * @since 1.0.0
 */
trait FieldsCollectionTraits
{
  protected ?FieldsCollectionEntity $fieldsCollection = null;

  /**
   * Get the fields collection entity.
   *
   * @since 1.0.0
   * @return FieldsCollectionEntity|null The fields collection entity or null if not set.
   */
  public function getFieldsCollection(): ?FieldsCollectionEntity
  {
    return $this->fieldsCollection;
  }

  /**
   * Set the fields collection entity.
   *
   * Stores a FieldsCollectionEntity instance and returns the current object
   * for method chaining.
   *
   * @since 1.0.0
   * @param FieldsCollectionEntity|null $fieldsCollection The fields collection entity to store.
   * @return self Returns the current object for method chaining.
   */
  public function setFieldsCollection(?FieldsCollectionEntity $fieldsCollection): self
  {
    $this->fieldsCollection = $fieldsCollection;
    return $this;
  }
}
