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/PositiveInteger.php.tar
uyarreklam.com.tr/httpdocs/wp-content/plugins/google-listings-and-ads/src/Value/PositiveInteger.php000064400000002165151547244400032534 0ustar00var/www/vhosts<?php
declare( strict_types=1 );

namespace Automattic\WooCommerce\GoogleListingsAndAds\Value;

use Automattic\WooCommerce\GoogleListingsAndAds\Exception\InvalidValue;

defined( 'ABSPATH' ) || exit;

/**
 * Class PositiveInteger
 *
 * @package Automattic\WooCommerce\GoogleListingsAndAds\Value
 */
class PositiveInteger implements CastableValueInterface, ValueInterface {

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

	/**
	 * PositiveInteger constructor.
	 *
	 * @param int $value The value.
	 *
	 * @throws InvalidValue When a negative integer is provided.
	 */
	public function __construct( int $value ) {
		$abs_value = absint( $value );
		if ( $abs_value !== $value ) {
			throw InvalidValue::negative_integer( __METHOD__ );
		}

		$this->value = $value;
	}

	/**
	 * Get the value of the object.
	 *
	 * @return int
	 */
	public function get() {
		return $this->value;
	}

	/**
	 * Cast a value and return a new instance of the class.
	 *
	 * @param mixed $value Mixed value to cast to class type.
	 *
	 * @return PositiveInteger
	 */
	public static function cast( $value ): PositiveInteger {
		return new self( absint( $value ) );
	}
}