1 | <?php |
||
10 | class Vouchers |
||
11 | { |
||
12 | /** @var VoucherGenerator */ |
||
13 | private $generator; |
||
14 | /** @var \BeyondCode\Vouchers\Models\Voucher */ |
||
15 | private $voucherModel; |
||
16 | |||
17 | public function __construct(VoucherGenerator $generator) |
||
22 | |||
23 | /** |
||
24 | * Generate the specified amount of codes and return |
||
25 | * an array with all the generated codes. |
||
26 | * |
||
27 | * @param int $amount |
||
28 | * @return array |
||
29 | */ |
||
30 | public function generate(int $amount = 1): array |
||
40 | |||
41 | /** |
||
42 | * @param Model $model |
||
43 | * @param int $amount |
||
44 | * @param array $data |
||
45 | * @param null $expires_at |
||
46 | * @return array |
||
47 | */ |
||
48 | public function create(Model $model, int $amount = 1, array $data = [], $expires_at = null) |
||
64 | |||
65 | /** |
||
66 | * @param string $code |
||
67 | * @throws VoucherIsInvalid |
||
68 | * @throws VoucherExpired |
||
69 | * @return Voucher |
||
70 | */ |
||
71 | public function check(string $code) |
||
84 | |||
85 | /** |
||
86 | * @return string |
||
87 | */ |
||
88 | protected function getUniqueVoucher(): string |
||
98 | } |
||
99 |