Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Coupon.php
1<?php
3
4class Coupon
5{
6 private string $coupon;
7
8 public function __construct(string $coupon)
9 {
10 $this->coupon = $coupon;
11 }
12
13 public function isCoupone(): bool
14 {
15 if (!preg_match("#^[A-Z0-9]{3}-[A-Z]{2}-?[A-Z0-9]{12,30}$#i", $this->coupon)
16 && !preg_match("#^[A-Z0-9]{3}-[A-Z0-9]{10}-[A-Z0-9]{10}$#i", $this->coupon))
17 {
18 return false;
19 }
20
21 return true;
22 }
23
24 public function getKey(): string
25 {
26 return $this->coupon;
27 }
28}
__construct(string $coupon)
Definition Coupon.php:8