* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\ValueObject; use PrestaShop\PrestaShop\Core\Domain\Product\SpecificPrice\ValueObject\SpecificPriceId as ProductSpecificPriceId; use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceConstraintException; @trigger_error( sprintf( '%s is deprecated since version 8.0.0 and will be removed in the next major version.', SpecificPriceId::class ), E_USER_DEPRECATED ); /** * @deprecated since 8.0.0 and will be removed in the next major version. * @see ProductSpecificPriceId */ class SpecificPriceId { /** * @var int */ private $specificPriceId; /** * @param int $specificPriceId * * @throws SpecificPriceConstraintException */ public function __construct(int $specificPriceId) { $this->assertIsGreaterThanZero($specificPriceId); $this->specificPriceId = $specificPriceId; } /** * @return int */ public function getValue(): int { return $this->specificPriceId; } /** * Validates that the value is greater than zero * * @param int $value * * @throws SpecificPriceConstraintException */ private function assertIsGreaterThanZero(int $value): void { if (!is_int($value) || 0 >= $value) { throw new SpecificPriceConstraintException(sprintf('Invalid specific price id "%s".', $value), SpecificPriceConstraintException::INVALID_ID); } } }