|
4 | 4 |
|
5 | 5 | use Swoole\Table;
|
6 | 6 |
|
7 |
| -if (SWOOLE_VERSION_ID === 40804 || SWOOLE_VERSION_ID >= 50000) { |
8 |
| - class SwooleTable extends Table |
| 7 | +class SwooleTable extends Table |
| 8 | +{ |
| 9 | + use Concerns\EnsuresColumnSizes; |
| 10 | + |
| 11 | + /** |
| 12 | + * The table columns. |
| 13 | + * |
| 14 | + * @var array |
| 15 | + */ |
| 16 | + protected $columns; |
| 17 | + |
| 18 | + /** |
| 19 | + * Set the data type and size of the columns. |
| 20 | + */ |
| 21 | + public function column(string $name, int $type, int $size = 0): bool |
9 | 22 | {
|
10 |
| - use Concerns\EnsuresColumnSizes; |
| 23 | + $this->columns[$name] = [$type, $size]; |
11 | 24 |
|
12 |
| - /** |
13 |
| - * The table columns. |
14 |
| - * |
15 |
| - * @var array |
16 |
| - */ |
17 |
| - protected $columns; |
18 |
| - |
19 |
| - /** |
20 |
| - * Set the data type and size of the columns. |
21 |
| - */ |
22 |
| - public function column(string $name, int $type, int $size = 0): bool |
23 |
| - { |
24 |
| - $this->columns[$name] = [$type, $size]; |
25 |
| - |
26 |
| - return parent::column($name, $type, $size); |
27 |
| - } |
28 |
| - |
29 |
| - /** |
30 |
| - * Update a row of the table. |
31 |
| - */ |
32 |
| - public function set(string $key, array $values): bool |
33 |
| - { |
34 |
| - collect($values) |
35 |
| - ->each($this->ensureColumnsSize()); |
36 |
| - |
37 |
| - return parent::set($key, $values); |
38 |
| - } |
| 25 | + return parent::column($name, $type, $size); |
39 | 26 | }
|
40 |
| -} else { |
41 |
| - class SwooleTable extends Table |
42 |
| - { |
43 |
| - use Concerns\EnsuresColumnSizes; |
44 | 27 |
|
45 |
| - /** |
46 |
| - * The table columns. |
47 |
| - * |
48 |
| - * @var array |
49 |
| - */ |
50 |
| - protected $columns; |
51 |
| - |
52 |
| - /** |
53 |
| - * Set the data type and size of the columns. |
54 |
| - * |
55 |
| - * @param string $name |
56 |
| - * @param int $type |
57 |
| - * @param int $size |
58 |
| - * @return void |
59 |
| - */ |
60 |
| - public function column($name, $type, $size = 0) |
61 |
| - { |
62 |
| - $this->columns[$name] = [$type, $size]; |
63 |
| - |
64 |
| - parent::column($name, $type, $size); |
65 |
| - } |
66 |
| - |
67 |
| - /** |
68 |
| - * Update a row of the table. |
69 |
| - * |
70 |
| - * @param string $key |
71 |
| - * @return void |
72 |
| - */ |
73 |
| - public function set($key, array $values) |
74 |
| - { |
75 |
| - collect($values) |
76 |
| - ->each($this->ensureColumnsSize()); |
| 28 | + /** |
| 29 | + * Update a row of the table. |
| 30 | + */ |
| 31 | + public function set(string $key, array $values): bool |
| 32 | + { |
| 33 | + collect($values) |
| 34 | + ->each($this->ensureColumnsSize()); |
77 | 35 |
|
78 |
| - parent::set($key, $values); |
79 |
| - } |
| 36 | + return parent::set($key, $values); |
80 | 37 | }
|
81 | 38 | }
|
0 commit comments