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