| Total Complexity | 8 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | trait TableMiddlewareTrait |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * 处理输入数据 |
||
| 10 | * |
||
| 11 | * @param string $name |
||
| 12 | * @param mixed $data |
||
| 13 | * @return mixed |
||
| 14 | */ |
||
| 15 | public function input(string $name, $data) |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * 处理输出数据 |
||
| 26 | * |
||
| 27 | * @param string $name |
||
| 28 | * @param mixed $data |
||
| 29 | * @return mixed |
||
| 30 | */ |
||
| 31 | public function output(string $name, $data) |
||
| 32 | { |
||
| 33 | $methodName = '_output'.ucfirst($name).'Field'; |
||
| 34 | if (\method_exists($this, $methodName)) { |
||
| 35 | return $this->$methodName($data); |
||
| 36 | } |
||
| 37 | return $data; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * 对输出列进行处理 |
||
| 42 | * |
||
| 43 | * @param mixed $row |
||
| 44 | * @return mixed |
||
| 45 | */ |
||
| 46 | public function outputRow($row) |
||
| 47 | { |
||
| 48 | $methodName = '_outputDataFilter'; |
||
| 49 | if (\method_exists($this, $methodName)) { |
||
| 50 | return $this->$methodName($row); |
||
| 51 | } |
||
| 52 | return $row; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * 输入参数名 |
||
| 57 | * |
||
| 58 | * @param string $name |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function inputName(string $name):string |
||
| 62 | { |
||
| 63 | return $name; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * 输出参数名 |
||
| 68 | * |
||
| 69 | * @param string $name |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | public function outputName(string $name):string |
||
| 75 | } |
||
| 76 | } |
||
| 77 |