Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 20 | class EE_File_Input extends EE_Form_Input_Base |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | protected $allowed_file_extensions; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var array |
||
| 29 | */ |
||
| 30 | protected $allowed_mime_types; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param array $options |
||
| 34 | * @throws InvalidArgumentException |
||
| 35 | */ |
||
| 36 | public function __construct($options = array()) |
||
| 74 | |||
| 75 | /** |
||
| 76 | * $_FILES has a really weird structure. So we let `FilesDataHandler` take care of finding the file info for |
||
| 77 | * this input. |
||
| 78 | * @since $VID:$ |
||
| 79 | * @param array $req_data |
||
| 80 | * @return FileSubmissionInterface |
||
| 81 | * @throws InvalidArgumentException |
||
| 82 | * @throws InvalidDataTypeException |
||
| 83 | * @throws InvalidInterfaceException |
||
| 84 | */ |
||
| 85 | public function find_form_data_for_this_section($req_data) |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Don't transform the file submission object into a string, thanks. |
||
| 96 | * |
||
| 97 | * @param string $value |
||
| 98 | * @return null|string |
||
| 99 | */ |
||
| 100 | protected function _sanitize($value) |
||
| 104 | } |
||
| 105 |