* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ namespace PrestaShop\Module\PrestashopCheckout\Cart\ValueObject; use PrestaShop\Module\PrestashopCheckout\Cart\Exception\CartException; class CartId { /** * @var int */ private $cartId; /** * @param int $cartId * * @throws CartException */ public function __construct($cartId) { $this->assertIntegerIsGreaterThanZero($cartId); $this->cartId = $cartId; } /** * @return int */ public function getValue() { return $this->cartId; } /** * @param int $cartId * * @throws CartException */ public function assertIntegerIsGreaterThanZero($cartId) { if (!is_int($cartId) || 0 >= $cartId) { throw new CartException(sprintf('Cart id %s is invalid. Cart id must be number that is greater than zero.', var_export($cartId, true)), CartException::INVALID_ID); } } }