<?php
/**
 * @license GPL-2.0-or-later
 *
 * Modified using Strauss.
 * @see https://github.com/BrianHenryIE/strauss
 */ declare(strict_types=1);

namespace RCP\LiquidWeb\LicensingApiClient\Resources\Concerns;

use RCP\LiquidWeb\LicensingApiClient\Http\RequestHeaderCollection;
use RCP\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsLedgerResource;
use RCP\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsPoolsResource;
use RCP\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsQuotasResource;
use RCP\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsResource;
use RCP\LiquidWeb\LicensingApiClient\Resources\EntitlementsResource;
use RCP\LiquidWeb\LicensingApiClient\Resources\LicensesResource;
use RCP\LiquidWeb\LicensingApiClient\Resources\ProductsResource;
use RCP\LiquidWeb\LicensingApiClient\Resources\TokensResource;

/**
 * Provides immutable request-header rebinding for resource views.
 *
 * @mixin CreditsLedgerResource
 * @mixin CreditsPoolsResource
 * @mixin CreditsQuotasResource
 * @mixin CreditsResource
 * @mixin EntitlementsResource
 * @mixin LicensesResource
 * @mixin ProductsResource
 * @mixin TokensResource
 */
trait RebindsRequestHeaderCollection
{
	public function withRequestHeaderCollection(RequestHeaderCollection $requestHeaderCollection): self {
		if ($this->requestHeaderCollection === $requestHeaderCollection) {
			return $this;
		}

		return $this->rebindWithRequestHeaderCollection($requestHeaderCollection);
	}

	abstract protected function rebindWithRequestHeaderCollection(RequestHeaderCollection $requestHeaderCollection): self;
}
