* @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\Customer\ValueObject; use PrestaShop\Module\PrestashopCheckout\Customer\Exception\CustomerException; class CustomerId { /** * @var int */ private $customerId; /** * @param int $customerId * * @throws CustomerException */ public function __construct($customerId) { $this->assertIntegerIsGreaterThanZero($customerId); $this->customerId = $customerId; } /** * @return int */ public function getValue() { return $this->customerId; } /** * @param int $customerId * * @throws CustomerException */ public function assertIntegerIsGreaterThanZero($customerId) { if (!is_int($customerId) || 0 >= $customerId) { throw new CustomerException(sprintf('Customer id %s is invalid. Customer id must be number that is greater than zero.', var_export($customerId, true)), CustomerException::INVALID_ID); } } }