HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/EnumeratedValues.php.tar
uyarreklam.com.tr/httpdocs/wp-content/plugins/google-listings-and-ads/src/Value/EnumeratedValues.php000064400000002100151547167350032662 0ustar00var/www/vhosts<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Value;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidType;

defined( 'ABSPATH' ) || exit;

/**
 * Class EnumeratedValues
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Value
 */
abstract class EnumeratedValues {

	/** @var string */
	protected $value;

	/**
	 * Array of possible valid values.
	 *
	 * Data will be validated to ensure it is one of these values.
	 *
	 * @var array
	 */
	protected $valid_values = [];

	/**
	 * EnumeratedValues constructor.
	 *
	 * @param string $value
	 */
	public function __construct( string $value ) {
		$this->validate_value( $value );
		$this->value = $value;
	}

	/**
	 * Validate the that value we received is one of the valid types.
	 *
	 * @param string $value
	 *
	 * @throws InvalidType When the value is not valid.
	 */
	protected function validate_value( string $value ) {
		if ( ! array_key_exists( $value, $this->valid_values ) ) {
			throw InvalidType::from_type( $value, array_keys( $this->valid_values ) );
		}
	}
}