We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 |
||
9 | trait CrudTrait |
||
10 | { |
||
11 | /* |
||
12 | |-------------------------------------------------------------------------- |
||
13 | | Methods for ENUM and SELECT crud fields. |
||
14 | |-------------------------------------------------------------------------- |
||
15 | */ |
||
16 | |||
17 | public static function getPossibleEnumValues($field_name) |
||
29 | |||
30 | public static function getEnumValuesAsAssociativeArray($field_name) |
||
43 | |||
44 | public static function isColumnNullable($column_name) |
||
54 | |||
55 | /* |
||
56 | |-------------------------------------------------------------------------- |
||
57 | | Methods for Fake Fields functionality (used in PageManager). |
||
58 | |-------------------------------------------------------------------------- |
||
59 | */ |
||
60 | |||
61 | /** |
||
62 | * Add fake fields as regular attributes, even though they are stored as JSON. |
||
63 | * |
||
64 | * @param array $columns - the database columns that contain the JSONs |
||
65 | */ |
||
66 | public function addFakes($columns = ['extras']) |
||
82 | |||
83 | /** |
||
84 | * Return the entity with fake fields as attributes. |
||
85 | * |
||
86 | * @param array $columns - the database columns that contain the JSONs |
||
87 | * |
||
88 | * @return Model |
||
89 | */ |
||
90 | public function withFakes($columns = []) |
||
102 | |||
103 | /* |
||
104 | |-------------------------------------------------------------------------- |
||
105 | | Methods for storing uploaded files (used in CRUD). |
||
106 | |-------------------------------------------------------------------------- |
||
107 | */ |
||
108 | |||
109 | /** |
||
110 | * Handle file upload and DB storage for a file: |
||
111 | * - on CREATE |
||
112 | * - stores the file at the destination path |
||
113 | * - generates a name |
||
114 | * - stores the full path in the DB; |
||
115 | * - on UPDATE |
||
116 | * - if the value is null, deletes the file and sets null in the DB |
||
117 | * - if the value is different, stores the different file and updates DB value. |
||
118 | * |
||
119 | * @param [type] $value Value for that column sent from the input. |
||
120 | * @param [type] $attribute_name Model attribute name (and column in the db). |
||
121 | * @param [type] $disk Filesystem disk used to store files. |
||
122 | * @param [type] $destination_path Path in disk where to store the files. |
||
123 | */ |
||
124 | public function uploadFileToDisk($value, $attribute_name, $disk, $destination_path) |
||
156 | |||
157 | /** |
||
158 | * Handle multiple file upload and DB storage: |
||
159 | * - if files are sent |
||
160 | * - stores the files at the destination path |
||
161 | * - generates random names |
||
162 | * - stores the full path in the DB, as JSON array; |
||
163 | * - if a hidden input is sent to clear one or more files |
||
164 | * - deletes the file |
||
165 | * - removes that file from the DB. |
||
166 | * |
||
167 | * @param [type] $value Value for that column sent from the input. |
||
168 | * @param [type] $attribute_name Model attribute name (and column in the db). |
||
169 | * @param [type] $disk Filesystem disk used to store files. |
||
170 | * @param [type] $destination_path Path in disk where to store the files. |
||
171 | */ |
||
172 | public function uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path) |
||
208 | } |
||
209 |
This check marks parameter names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.