| Total Complexity | 71 |
| Total Lines | 777 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like ItemModel often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ItemModel, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 35 | class ItemModel |
||
| 36 | { |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get the list of items to return |
||
| 40 | * |
||
| 41 | * @param string $sqlExtra |
||
| 42 | * @param integer $limit |
||
| 43 | * @param string $userPrivateKey |
||
| 44 | * @param integer $userId |
||
| 45 | * |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | public function getItems(string $sqlExtra, int $limit, string $userPrivateKey, int $userId): array |
||
| 49 | { |
||
| 50 | // Get items |
||
| 51 | $rows = DB::query( |
||
| 52 | 'SELECT i.id, label, description, i.pw, i.url, i.id_tree, i.login, i.email, i.viewed_no, i.fa_icon, i.inactif, i.perso, |
||
| 53 | t.title as folder_label, io.secret as otp_secret |
||
| 54 | FROM ' . prefixTable('items') . ' AS i |
||
| 55 | LEFT JOIN '.prefixTable('nested_tree').' as t ON (t.id = i.id_tree) |
||
| 56 | LEFT JOIN '.prefixTable('items_otp').' as io ON (io.item_id = i.id) '. |
||
| 57 | $sqlExtra . |
||
| 58 | " ORDER BY i.id ASC" . |
||
| 59 | ($limit > 0 ? " LIMIT ". $limit : '') |
||
| 60 | ); |
||
| 61 | |||
| 62 | $ret = []; |
||
| 63 | foreach ($rows as $row) { |
||
| 64 | $userKey = DB::queryfirstrow( |
||
| 65 | 'SELECT share_key |
||
| 66 | FROM ' . prefixTable('sharekeys_items') . ' |
||
| 67 | WHERE user_id = %i AND object_id = %i', |
||
| 68 | $userId, |
||
| 69 | $row['id'] |
||
| 70 | ); |
||
| 71 | if (DB::count() === 0 || empty($row['pw']) === true) { |
||
| 72 | // No share key found |
||
| 73 | // Exit this item |
||
| 74 | continue; |
||
| 75 | } |
||
| 76 | |||
| 77 | // Get password |
||
| 78 | try { |
||
| 79 | $pwd = base64_decode( |
||
| 80 | (string) doDataDecryption( |
||
| 81 | $row['pw'], |
||
| 82 | decryptUserObjectKey( |
||
| 83 | $userKey['share_key'], |
||
| 84 | $userPrivateKey |
||
| 85 | ) |
||
| 86 | ) |
||
| 87 | ); |
||
| 88 | } catch (Exception $e) { |
||
| 89 | // Password is not encrypted |
||
| 90 | // deepcode ignore ServerLeak: No important data |
||
| 91 | echo "ERROR"; |
||
| 92 | } |
||
| 93 | |||
| 94 | |||
| 95 | // get path to item |
||
| 96 | $tree = new NestedTree(prefixTable('nested_tree'), 'id', 'parent_id', 'title'); |
||
| 97 | $arbo = $tree->getPath($row['id_tree'], false); |
||
| 98 | $path = ''; |
||
| 99 | foreach ($arbo as $elem) { |
||
| 100 | if (empty($path) === true) { |
||
| 101 | $path = htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
||
| 102 | } else { |
||
| 103 | $path .= '/' . htmlspecialchars(stripslashes(htmlspecialchars_decode($elem->title, ENT_QUOTES)), ENT_QUOTES); |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | // Get TOTP |
||
| 108 | if (empty($row['otp_secret']) === false) { |
||
| 109 | $decryptedTotp = cryption( |
||
| 110 | $row['otp_secret'], |
||
| 111 | '', |
||
| 112 | 'decrypt' |
||
| 113 | ); |
||
| 114 | $row['otp_secret'] = $decryptedTotp['string']; |
||
| 115 | } |
||
| 116 | |||
| 117 | array_push( |
||
| 118 | $ret, |
||
| 119 | [ |
||
| 120 | 'id' => (int) $row['id'], |
||
| 121 | 'label' => $row['label'], |
||
| 122 | 'description' => $row['description'], |
||
| 123 | 'pwd' => $pwd, |
||
| 124 | 'url' => $row['url'], |
||
| 125 | 'login' => $row['login'], |
||
| 126 | 'email' => $row['email'], |
||
| 127 | 'viewed_no' => (int) $row['viewed_no'], |
||
| 128 | 'fa_icon' => $row['fa_icon'], |
||
| 129 | 'inactif' => (int) $row['inactif'], |
||
| 130 | 'perso' => (int) $row['perso'], |
||
| 131 | 'id_tree' => (int) $row['id_tree'], |
||
| 132 | 'folder_label' => $row['folder_label'], |
||
| 133 | 'path' => empty($path) === true ? '' : $path, |
||
| 134 | 'totp' => $row['otp_secret'], |
||
| 135 | ] |
||
| 136 | ); |
||
| 137 | } |
||
| 138 | |||
| 139 | return $ret; |
||
| 140 | } |
||
| 141 | //end getItems() |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Main function to add a new item to the database. |
||
| 145 | * It handles data preparation, validation, password checks, folder settings, |
||
| 146 | * item creation, and post-insertion tasks (like logging, sharing, and tagging). |
||
| 147 | */ |
||
| 148 | public function addItem( |
||
| 149 | int $folderId, |
||
| 150 | string $label, |
||
| 151 | string $password, |
||
| 152 | string $description, |
||
| 153 | string $login, |
||
| 154 | string $email, |
||
| 155 | string $url, |
||
| 156 | string $tags, |
||
| 157 | string $anyone_can_modify, |
||
| 158 | string $icon, |
||
| 159 | int $userId, |
||
| 160 | string $username, |
||
| 161 | string $totp |
||
| 162 | ) : array |
||
| 163 | { |
||
| 164 | try { |
||
| 165 | include_once API_ROOT_PATH . '/../sources/main.functions.php'; |
||
| 166 | |||
| 167 | // Load config |
||
| 168 | $configManager = new ConfigManager(); |
||
| 169 | $SETTINGS = $configManager->getAllSettings(); |
||
| 170 | |||
| 171 | // Step 1: Prepare data and sanitize inputs |
||
| 172 | $data = $this->prepareData($folderId, $label, $password, $description, $login, $email, $url, $tags, $anyone_can_modify, $icon, $totp); |
||
| 173 | $this->validateData($data); // Step 2: Validate the data |
||
| 174 | |||
| 175 | // Step 3: Validate password rules (length, emptiness) |
||
| 176 | $this->validatePassword($password, $SETTINGS); |
||
| 177 | |||
| 178 | // Step 4: Check folder settings for permission checks |
||
| 179 | $itemInfos = $this->getFolderSettings($folderId); |
||
| 180 | |||
| 181 | // Step 5: Ensure the password meets folder complexity requirements |
||
| 182 | $this->checkPasswordComplexity($password, $itemInfos); |
||
| 183 | |||
| 184 | // Step 6: Check for duplicates in the system |
||
| 185 | $this->checkForDuplicates($label, $SETTINGS, $itemInfos); |
||
| 186 | |||
| 187 | // Step 7: Encrypt password if provided |
||
| 188 | $cryptedData = $this->encryptPassword($password); |
||
| 189 | $passwordKey = $cryptedData['passwordKey']; |
||
| 190 | $password = $cryptedData['encrypted']; |
||
| 191 | |||
| 192 | // Step 8: Insert the new item into the database |
||
| 193 | $newID = $this->insertNewItem($data, $password, $itemInfos); |
||
| 194 | |||
| 195 | // Step 9: Handle post-insert tasks (logging, sharing, tagging) |
||
| 196 | $this->handlePostInsertTasks($newID, $itemInfos, $folderId, $passwordKey, $userId, $username, $tags, $data, $SETTINGS); |
||
| 197 | |||
| 198 | // Success response |
||
| 199 | return [ |
||
| 200 | 'error' => false, |
||
| 201 | 'message' => 'Item added successfully', |
||
| 202 | 'newId' => $newID, |
||
| 203 | ]; |
||
| 204 | |||
| 205 | } catch (Exception $e) { |
||
| 206 | // Error response |
||
| 207 | return [ |
||
| 208 | 'error' => true, |
||
| 209 | 'error_header' => 'HTTP/1.1 422 Unprocessable Entity', |
||
| 210 | 'error_message' => $e->getMessage(), |
||
| 211 | ]; |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Prepares the data array for processing by combining all inputs. |
||
| 217 | * @param int $folderId - Folder ID where the item is stored |
||
| 218 | * @param string $label - Label or title of the item |
||
| 219 | * @param string $password - Password associated with the item |
||
| 220 | * @param string $description - Description of the item |
||
| 221 | * @param string $login - Login associated with the item |
||
| 222 | * @param string $email - Email linked to the item |
||
| 223 | * @param string $url - URL for the item |
||
| 224 | * @param string $tags - Tags for categorizing the item |
||
| 225 | * @param string $anyone_can_modify - Permission to allow modifications by others |
||
| 226 | * @param string $icon - Icon representing the item |
||
| 227 | * @param string $totp - Token for OTP |
||
| 228 | * @return array - Returns the prepared data |
||
| 229 | */ |
||
| 230 | private function prepareData( |
||
| 246 | ]; |
||
| 247 | } |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Sanitizes and validates the input data according to specified filters. |
||
| 251 | * If validation fails, throws an exception. |
||
| 252 | * @param array $data - Data to be validated and sanitized |
||
| 253 | * @throws Exception - If the data is invalid |
||
| 254 | */ |
||
| 255 | private function validateData(array $data) : void |
||
| 256 | { |
||
| 257 | $filters = [ |
||
| 258 | 'folderId' => 'cast:integer', |
||
| 259 | 'label' => 'trim|escape', |
||
| 260 | 'password' => 'trim|escape', |
||
| 261 | 'description' => 'trim|escape', |
||
| 262 | 'login' => 'trim|escape', |
||
| 263 | 'email' => 'trim|escape', |
||
| 264 | 'tags' => 'trim|escape', |
||
| 265 | 'anyoneCanModify' => 'trim|escape', |
||
| 266 | 'url' => 'trim|escape', |
||
| 267 | 'icon' => 'trim|escape', |
||
| 268 | 'totp' => 'trim|escape', |
||
| 269 | ]; |
||
| 270 | |||
| 271 | $inputData = dataSanitizer($data, $filters); |
||
| 272 | if (is_string($inputData)) { |
||
| 273 | throw new Exception('Data is not valid'); |
||
| 274 | } |
||
| 275 | } |
||
| 276 | |||
| 277 | /** |
||
| 278 | * Validates the password against length and empty password rules. |
||
| 279 | * Throws an exception if validation fails. |
||
| 280 | * @param string $password - The password to validate |
||
| 281 | * @param array $SETTINGS - Global settings from configuration |
||
| 282 | * @throws Exception - If the password is invalid |
||
| 283 | */ |
||
| 284 | private function validatePassword(string $password, array $SETTINGS) : void |
||
| 285 | { |
||
| 286 | if ($this->isPasswordEmptyAllowed($password, $SETTINGS['create_item_without_password'])) { |
||
| 287 | throw new Exception('Empty password is not allowed'); |
||
| 288 | } |
||
| 289 | |||
| 290 | if (strlen($password) > $SETTINGS['pwd_maximum_length']) { |
||
| 291 | throw new Exception('Password is too long (max allowed is ' . $SETTINGS['pwd_maximum_length'] . ' characters)'); |
||
| 292 | } |
||
| 293 | } |
||
| 294 | |||
| 295 | /** |
||
| 296 | * Retrieves folder-specific settings, including permission to modify and create items. |
||
| 297 | * @param int $folderId - The folder ID to fetch settings for |
||
| 298 | * @return array - Returns an array with folder-specific permissions |
||
| 299 | */ |
||
| 300 | private function getFolderSettings(int $folderId) : array |
||
| 301 | { |
||
| 302 | $dataFolderSettings = DB::queryFirstRow( |
||
| 303 | 'SELECT bloquer_creation, bloquer_modification, personal_folder |
||
| 304 | FROM ' . prefixTable('nested_tree') . ' |
||
| 305 | WHERE id = %i', |
||
| 306 | $folderId |
||
| 307 | ); |
||
| 308 | |||
| 309 | return [ |
||
| 310 | 'personal_folder' => $dataFolderSettings['personal_folder'], |
||
| 311 | 'no_complex_check_on_modification' => (int) $dataFolderSettings['personal_folder'] === 1 ? 1 : (int) $dataFolderSettings['bloquer_modification'], |
||
| 312 | 'no_complex_check_on_creation' => (int) $dataFolderSettings['personal_folder'] === 1 ? 1 : (int) $dataFolderSettings['bloquer_creation'], |
||
| 313 | ]; |
||
| 314 | } |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Validates that the password meets the complexity requirements of the folder. |
||
| 318 | * Throws an exception if the password is too weak. |
||
| 319 | * @param string $password - The password to check |
||
| 320 | * @param array $itemInfos - Folder settings including password complexity requirements |
||
| 321 | * @throws Exception - If the password complexity is insufficient |
||
| 322 | */ |
||
| 323 | private function checkPasswordComplexity(string $password, array $itemInfos) : void |
||
| 324 | { |
||
| 325 | $folderComplexity = DB::queryFirstRow( |
||
| 326 | 'SELECT valeur |
||
| 327 | FROM ' . prefixTable('misc') . ' |
||
| 328 | WHERE type = %s AND intitule = %i', |
||
| 329 | 'complex', |
||
| 330 | $itemInfos['folderId'] |
||
| 331 | ); |
||
| 332 | |||
| 333 | $requested_folder_complexity = $folderComplexity !== null ? (int) $folderComplexity['valeur'] : 0; |
||
| 334 | |||
| 335 | $zxcvbn = new Zxcvbn(); |
||
| 336 | $passwordStrength = $zxcvbn->passwordStrength($password); |
||
| 337 | $passwordStrengthScore = convertPasswordStrength($passwordStrength['score']); |
||
| 338 | |||
| 339 | if ($passwordStrengthScore < $requested_folder_complexity && (int) $itemInfos['no_complex_check_on_creation'] === 0) { |
||
| 340 | throw new Exception('Password strength is too low'); |
||
| 341 | } |
||
| 342 | } |
||
| 343 | |||
| 344 | /** |
||
| 345 | * Checks if an item with the same label already exists in the folder. |
||
| 346 | * Throws an exception if duplicates are not allowed. |
||
| 347 | * @param string $label - The label of the item to check for duplicates |
||
| 348 | * @param array $SETTINGS - Global settings for duplicate items |
||
| 349 | * @param array $itemInfos - Folder-specific settings |
||
| 350 | * @throws Exception - If a duplicate item is found and not allowed |
||
| 351 | */ |
||
| 352 | private function checkForDuplicates(string $label, array $SETTINGS, array $itemInfos) : void |
||
| 353 | { |
||
| 354 | DB::queryFirstRow( |
||
| 355 | 'SELECT * FROM ' . prefixTable('items') . ' |
||
| 356 | WHERE label = %s AND inactif = %i', |
||
| 357 | $label, |
||
| 358 | 0 |
||
| 359 | ); |
||
| 360 | |||
| 361 | if (DB::count() > 0 && ( |
||
| 362 | (isset($SETTINGS['duplicate_item']) && (int) $SETTINGS['duplicate_item'] === 0) |
||
| 363 | && (int) $itemInfos['personal_folder'] === 0) |
||
| 364 | ) { |
||
| 365 | throw new Exception('Similar item already exists. Duplicates are not allowed.'); |
||
| 366 | } |
||
| 367 | } |
||
| 368 | |||
| 369 | /** |
||
| 370 | * Encrypts the password using the system's encryption function. |
||
| 371 | * Returns an array containing both the encrypted password and the encryption key. |
||
| 372 | * @param string $password - The password to encrypt |
||
| 373 | * @return array - Returns the encrypted password and the encryption key |
||
| 374 | */ |
||
| 375 | private function encryptPassword(string $password) : array |
||
| 376 | { |
||
| 377 | $cryptedStuff = doDataEncryption($password); |
||
| 378 | return [ |
||
| 379 | 'encrypted' => $cryptedStuff['encrypted'], |
||
| 380 | 'passwordKey' => $cryptedStuff['objectKey'], |
||
| 381 | ]; |
||
| 382 | } |
||
| 383 | |||
| 384 | /** |
||
| 385 | * Inserts the new item into the database with all its associated data. |
||
| 386 | * @param array $data - The item data to insert |
||
| 387 | * @param string $password - The encrypted password |
||
| 388 | * @param array $itemInfos - Folder-specific settings |
||
| 389 | * @return int - Returns the ID of the newly created item |
||
| 390 | */ |
||
| 391 | private function insertNewItem(array $data, string $password, array $itemInfos) : int |
||
| 392 | { |
||
| 393 | include_once API_ROOT_PATH . '/../sources/main.functions.php'; |
||
| 394 | |||
| 395 | DB::insert( |
||
| 396 | prefixTable('items'), |
||
| 397 | [ |
||
| 398 | 'label' => $data['label'], |
||
| 399 | 'description' => $data['description'], |
||
| 400 | 'pw' => $password, |
||
| 401 | 'pw_iv' => '', |
||
| 402 | 'pw_len' => strlen($data['password']), |
||
| 403 | 'email' => $data['email'], |
||
| 404 | 'url' => $data['url'], |
||
| 405 | 'id_tree' => $data['folderId'], |
||
| 406 | 'login' => $data['login'], |
||
| 407 | 'inactif' => 0, |
||
| 408 | 'restricted_to' => '', |
||
| 409 | 'perso' => $itemInfos['personal_folder'], |
||
| 410 | 'anyone_can_modify' => $data['anyoneCanModify'], |
||
| 411 | 'complexity_level' => $this->getPasswordComplexityLevel($password), |
||
| 412 | 'encryption_type' => 'teampass_aes', |
||
| 413 | 'fa_icon' => $data['icon'], |
||
| 414 | 'item_key' => uniqidReal(50), |
||
| 415 | 'created_at' => time(), |
||
| 416 | ] |
||
| 417 | ); |
||
| 418 | |||
| 419 | $newItemId = DB::insertId(); |
||
| 420 | |||
| 421 | // Handle TOTP if provided |
||
| 422 | if (empty($data['totp']) === true) { |
||
| 423 | $encryptedSecret = cryption( |
||
| 424 | $data['totp'], |
||
| 425 | '', |
||
| 426 | 'encrypt' |
||
| 427 | ); |
||
| 428 | |||
| 429 | DB::insert( |
||
| 430 | prefixTable('items_otp'), |
||
| 431 | array( |
||
| 432 | 'item_id' => $newItemId, |
||
| 433 | 'secret' => $encryptedSecret['string'], |
||
| 434 | 'phone_number' => '', |
||
| 435 | 'timestamp' => time(), |
||
| 436 | 'enabled' => 1, |
||
| 437 | ) |
||
| 438 | ); |
||
| 439 | } |
||
| 440 | |||
| 441 | return $newItemId; |
||
| 442 | } |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Determines the complexity level of a password based on its strength score. |
||
| 446 | * @param string $password - The encrypted password for which complexity is being evaluated |
||
| 447 | * @return int - Returns the complexity level (0 for weak, higher numbers for stronger passwords) |
||
| 448 | */ |
||
| 449 | private function getPasswordComplexityLevel(string $password) : int |
||
| 450 | { |
||
| 451 | $zxcvbn = new Zxcvbn(); |
||
| 452 | $passwordStrength = $zxcvbn->passwordStrength($password); |
||
| 453 | return convertPasswordStrength($passwordStrength['score']); |
||
| 454 | } |
||
| 455 | |||
| 456 | /** |
||
| 457 | * Handles tasks that need to be performed after the item is inserted: |
||
| 458 | * 1. Stores sharing keys |
||
| 459 | * 2. Logs the item creation |
||
| 460 | * 3. Adds a task if the folder is not personal |
||
| 461 | * 4. Adds tags to the item |
||
| 462 | * @param int $newID - The ID of the newly created item |
||
| 463 | * @param array $itemInfos - Folder-specific settings |
||
| 464 | * @param int $folderId - Folder ID of the item |
||
| 465 | * @param string $passwordKey - The encryption key for the item |
||
| 466 | * @param int $userId - ID of the user creating the item |
||
| 467 | * @param string $username - Username of the creator |
||
| 468 | * @param string $tags - Tags to be associated with the item |
||
| 469 | * @param array $data - The original data used to create the item (including the label) |
||
| 470 | * @param array $SETTINGS - System settings for logging and task creation |
||
| 471 | */ |
||
| 472 | private function handlePostInsertTasks( |
||
| 473 | int $newID, |
||
| 474 | array $itemInfos, |
||
| 475 | int $folderId, |
||
| 476 | string $passwordKey, |
||
| 477 | int $userId, |
||
| 478 | string $username, |
||
| 479 | string $tags, |
||
| 480 | array $data, |
||
| 481 | array $SETTINGS |
||
| 482 | ) : void { |
||
| 483 | // Create share keys for the creator |
||
| 484 | storeUsersShareKey( |
||
| 485 | 'sharekeys_items', |
||
| 486 | (int) $itemInfos['personal_folder'], |
||
| 487 | (int) $newID, |
||
| 488 | $passwordKey, |
||
| 489 | true, |
||
| 490 | false, |
||
| 491 | [], |
||
| 492 | -1, |
||
| 493 | $userId |
||
| 494 | ); |
||
| 495 | |||
| 496 | // Log the item creation |
||
| 497 | logItems($SETTINGS, $newID, $data['label'], $userId, 'at_creation', $username); |
||
| 498 | |||
| 499 | // Create a task if the folder is not personal |
||
| 500 | if ((int) $itemInfos['personal_folder'] === 0) { |
||
| 501 | storeTask('new_item', $userId, 0, $folderId, $newID, $passwordKey, [], []); |
||
| 502 | } |
||
| 503 | |||
| 504 | // Add tags to the item |
||
| 505 | $this->addTags($newID, $tags); |
||
| 506 | } |
||
| 507 | |||
| 508 | |||
| 509 | /** |
||
| 510 | * Splits the tags string into individual tags and inserts them into the database. |
||
| 511 | * @param int $newID - The ID of the item to associate tags with |
||
| 512 | * @param string $tags - A comma-separated string of tags |
||
| 513 | */ |
||
| 514 | private function addTags(int $newID, string $tags) : void |
||
| 515 | { |
||
| 516 | $tagsArray = explode(',', $tags); |
||
| 517 | foreach ($tagsArray as $tag) { |
||
| 518 | if (!empty($tag)) { |
||
| 519 | DB::insert( |
||
| 520 | prefixTable('tags'), |
||
| 521 | ['item_id' => $newID, 'tag' => strtolower($tag)] |
||
| 522 | ); |
||
| 523 | } |
||
| 524 | } |
||
| 525 | } |
||
| 526 | |||
| 527 | |||
| 528 | private function isPasswordEmptyAllowed($password, $create_item_without_password) |
||
| 529 | { |
||
| 530 | if ( |
||
| 531 | empty($password) === true |
||
| 532 | && null !== $create_item_without_password |
||
| 533 | && (int) $create_item_without_password !== 1 |
||
| 534 | ) { |
||
| 535 | return true; |
||
| 536 | } |
||
| 537 | return false; |
||
| 538 | } |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Main function to update an existing item in the database. |
||
| 542 | * It handles data validation, password encryption, folder permission checks, |
||
| 543 | * and updates the item with the provided fields. |
||
| 544 | * |
||
| 545 | * @param int $itemId The ID of the item to update |
||
| 546 | * @param array $params Array of parameters to update |
||
| 547 | * @param array $userData User data from JWT token |
||
| 548 | * @param string $userPrivateKey User's private key for encryption |
||
| 549 | * @return array Returns success or error response |
||
| 550 | */ |
||
| 551 | public function updateItem( |
||
| 749 | ]; |
||
| 750 | } |
||
| 751 | } |
||
| 752 | |||
| 753 | /** |
||
| 754 | * Main function to delete an existing item in the database. |
||
| 755 | * |
||
| 756 | * @param int $itemId The ID of the item to delete |
||
| 757 | * @param array $userData User data from JWT token |
||
| 758 | * @return array Returns success or error response |
||
| 759 | */ |
||
| 760 | public function deleteItem( |
||
| 812 | ]; |
||
| 813 | } |
||
| 814 | } |
||
| 817 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.