Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 17 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
16 | View Code Duplication | public function parseRequest($request) { |
|
1 ignored issue
–
show
|
|||
17 | if (!empty($_FILES[$this->activeForm->requestFormName]['tmp_name'][$this->modelName][$this->colName])) { |
||
18 | $file_id = \App::$primary->files->upload([ |
||
19 | 'tmp_name' => $_FILES[$this->activeForm->requestFormName]['tmp_name'][$this->modelName][$this->colName], |
||
20 | 'name' => $_FILES[$this->activeForm->requestFormName]['name'][$this->modelName][$this->colName], |
||
21 | 'type' => $_FILES[$this->activeForm->requestFormName]['type'][$this->modelName][$this->colName], |
||
22 | 'size' => $_FILES[$this->activeForm->requestFormName]['size'][$this->modelName][$this->colName], |
||
23 | 'error' => $_FILES[$this->activeForm->requestFormName]['error'][$this->modelName][$this->colName], |
||
24 | ], [ |
||
25 | 'upload_code' => 'activeForm:' . $this->activeForm->modelName . ':' . $this->activeForm->model->pk() |
||
26 | ]); |
||
27 | |||
28 | if ($file_id) { |
||
29 | $this->activeForm->model->{$this->colName} = $file_id; |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | |||
35 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: