Total Complexity | 4 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | class SwooleTable |
||
8 | { |
||
9 | /** |
||
10 | * Registered swoole tables. |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | protected $tables = []; |
||
15 | |||
16 | /** |
||
17 | * Add a swoole table to existing tables. |
||
18 | * |
||
19 | * @param string $name |
||
20 | * @param \Swoole\Table $table |
||
21 | * |
||
22 | * @return \SwooleTW\Http\Table\SwooleTable |
||
23 | */ |
||
24 | public function add(string $name, Table $table) |
||
25 | { |
||
26 | $this->tables[$name] = $table; |
||
27 | |||
28 | return $this; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Get a swoole table by its name from existing tables. |
||
33 | * |
||
34 | * @param string $name |
||
35 | * |
||
36 | * @return \Swoole\Table $table |
||
37 | */ |
||
38 | public function get(string $name) |
||
39 | { |
||
40 | return $this->tables[$name] ?? null; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Get all existing swoole tables. |
||
45 | * |
||
46 | * @return array |
||
47 | */ |
||
48 | public function getAll() |
||
49 | { |
||
50 | return $this->tables; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Dynamically access table. |
||
55 | * |
||
56 | * @param string $key |
||
57 | * |
||
58 | * @return table |
||
59 | */ |
||
60 | public function __get($key) |
||
63 | } |
||
64 | } |
||
65 |