|
4 | 4 |
|
5 | 5 | use Codeception\Module\Sequence; |
6 | 6 |
|
7 | | -if (!function_exists('sq')) { |
8 | | - function sq($id = null) |
9 | | - { |
10 | | - if ($id && isset(Sequence::$hash[$id])) { |
11 | | - return Sequence::$hash[$id]; |
12 | | - } |
13 | | - |
14 | | - $prefix = str_replace('{id}', $id, Sequence::$prefix); |
15 | | - $sequence = $prefix . uniqid($id); |
16 | | - if ($id) { |
17 | | - Sequence::$hash[$id] = $sequence; |
18 | | - } |
19 | | - |
20 | | - return $sequence; |
| 7 | +function sq(int|string $id = null): string |
| 8 | +{ |
| 9 | + if ($id && isset(Sequence::$hash[$id])) { |
| 10 | + return Sequence::$hash[$id]; |
| 11 | + } |
| 12 | + |
| 13 | + $prefix = str_replace('{id}', (string)$id, Sequence::$prefix); |
| 14 | + $sequence = $prefix . uniqid((string)$id); |
| 15 | + if ($id) { |
| 16 | + Sequence::$hash[$id] = $sequence; |
21 | 17 | } |
22 | | -} |
23 | 18 |
|
24 | | -if (!function_exists('sqs')) { |
25 | | - function sqs($id = null) |
26 | | - { |
27 | | - if ($id && isset(Sequence::$suiteHash[$id])) { |
28 | | - return Sequence::$suiteHash[$id]; |
29 | | - } |
| 19 | + return $sequence; |
| 20 | +} |
30 | 21 |
|
31 | | - $prefix = str_replace('{id}', $id, Sequence::$prefix); |
32 | | - $sequence = $prefix . uniqid($id); |
33 | | - if ($id) { |
34 | | - Sequence::$suiteHash[$id] = $sequence; |
35 | | - } |
| 22 | +function sqs(int|string $id = null): string |
| 23 | +{ |
| 24 | + if ($id && isset(Sequence::$suiteHash[$id])) { |
| 25 | + return Sequence::$suiteHash[$id]; |
| 26 | + } |
36 | 27 |
|
37 | | - return $sequence; |
| 28 | + $prefix = str_replace('{id}', (string)$id, Sequence::$prefix); |
| 29 | + $sequence = $prefix . uniqid((string)$id); |
| 30 | + if ($id) { |
| 31 | + Sequence::$suiteHash[$id] = $sequence; |
38 | 32 | } |
| 33 | + |
| 34 | + return $sequence; |
39 | 35 | } |
0 commit comments