* @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\Product\Combination\ValueObject; use PrestaShop\PrestaShop\Core\Domain\Product\Combination\Exception\CombinationConstraintException; /** * Holds product combination identification data */ class CombinationId implements CombinationIdInterface { /** * Indicates that no combination is provided/selected * * @deprecated since 8.0.0 and will be removed in next major version. * @see NoCombinationId instead */ public const NO_COMBINATION = 0; /** * @var int */ private $combinationId; /** * @param int $combinationId * * @throws CombinationConstraintException */ public function __construct(int $combinationId) { $this->assertValueIsPositive($combinationId); $this->combinationId = $combinationId; } /** * @return int */ public function getValue(): int { return $this->combinationId; } /** * @param int $value * * @throws CombinationConstraintException */ private function assertValueIsPositive(int $value) { if (0 >= $value) { throw new CombinationConstraintException( sprintf('Combination id must be positive integer. "%s" given', $value), CombinationConstraintException::INVALID_ID ); } } }