Conditions | 11 |
Paths | 50 |
Total Lines | 52 |
Code Lines | 41 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
25 | public function process(): void |
||
26 | { |
||
27 | if ($this->checkExceptions('CreatedHelpDesk')) { |
||
28 | return; |
||
29 | } |
||
30 | $scanner = $this->scannerEngine; |
||
31 | if (($prefix = RecordFinder::getRecordNumberFromString($scanner->get('subject'), 'HelpDesk')) && \App\Record::getIdByRecordNumber($prefix, 'HelpDesk')) { |
||
32 | return; |
||
33 | } |
||
34 | $fromEmail = [$scanner->get('from_email')]; |
||
35 | $contactId = current(\App\Utils::flatten(RecordFinder::findByEmail($fromEmail, $scanner->getEmailsFields('Contacts')))); |
||
36 | $parentId = current(\App\Utils::flatten(RecordFinder::findByEmail($fromEmail, $scanner->getEmailsFields('Accounts')))); |
||
37 | if (!$parentId) { |
||
38 | $parentId = current(\App\Utils::flatten(RecordFinder::findByEmail($fromEmail, $scanner->getEmailsFields('Vendors')))); |
||
39 | } |
||
40 | if (!$parentId && $contactId) { |
||
41 | $parentId = \App\Record::getParentRecord($contactId, 'Contacts'); |
||
42 | } |
||
43 | $recordModel = \Vtiger_Record_Model::getCleanInstance('HelpDesk'); |
||
44 | $this->loadServiceContracts($recordModel, $parentId); |
||
45 | $recordModel->set('assigned_user_id', $scanner->getUserId()); |
||
46 | $recordModel->set('created_user_id', $scanner->getUserId()); |
||
47 | $recordModel->set('createdtime', $scanner->get('date')); |
||
48 | $recordModel->setFromUserValue('ticket_title', \App\TextUtils::textTruncate($scanner->get('subject'), $recordModel->getField('ticket_title')->getMaxValue(), false)); |
||
49 | $recordModel->set('description', \App\TextUtils::htmlTruncate($scanner->get('body'), $recordModel->getField('description')->getMaxValue())); |
||
50 | $recordModel->set('ticketstatus', \Config\Modules\OSSMailScanner::$helpdeskCreateDefaultStatus); |
||
|
|||
51 | if ($contactId) { |
||
52 | $recordModel->ext['relations'][] = [ |
||
53 | 'relatedModule' => 'Contacts', |
||
54 | 'relatedRecords' => [$contactId], |
||
55 | ]; |
||
56 | } |
||
57 | if ($mailId = $scanner->getMailCrmId()) { |
||
58 | $recordModel->ext['relations'][] = [ |
||
59 | 'reverse' => true, |
||
60 | 'relatedModule' => 'OSSMailView', |
||
61 | 'relatedRecords' => [$mailId], |
||
62 | 'params' => $scanner->get('date'), |
||
63 | ]; |
||
64 | } |
||
65 | $recordModel->save(); |
||
66 | $id = $recordModel->getId(); |
||
67 | $scanner->processData['CreatedHelpDesk'] = $id; |
||
68 | if ($mailId) { |
||
69 | $dbCommand = \App\Db::getInstance()->createCommand(); |
||
70 | $query = (new \App\Db\Query())->select(['documentsid'])->from('vtiger_ossmailview_files')->where(['ossmailviewid' => $mailId]); |
||
71 | $dataReader = $query->createCommand()->query(); |
||
72 | while ($documentId = $dataReader->readColumn(0)) { |
||
73 | $dbCommand->insert('vtiger_senotesrel', ['crmid' => $id, 'notesid' => $documentId])->execute(); |
||
74 | } |
||
75 | $dataReader->close(); |
||
76 | unset($dataReader,$query, $dbCommand, $recordModel); |
||
77 | } |
||
111 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths