* @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\Feature\ValueObject; use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\InvalidFeatureIdException; /** * Defines Feature ID with its constraints. */ class FeatureId { /** * @var int */ private $featureId; /** * @param int $featureId */ public function __construct($featureId) { $this->assertIntegerIsGreaterThanZero($featureId); $this->featureId = $featureId; } /** * @return int */ public function getValue() { return $this->featureId; } /** * @param int $featureId * * @throws InvalidFeatureIdException */ private function assertIntegerIsGreaterThanZero($featureId): void { if (!is_int($featureId) || 0 > $featureId) { throw new InvalidFeatureIdException(sprintf('Invalid feature id %s supplied. Feature id must be positive integer.', var_export($featureId, true))); } } }