Passed
Push — developer ( 4e3135...f5c82a )
by Radosław
30:25 queued 12:59
created

OpenHelpDesk::process()   B

Complexity

Conditions 10
Paths 7

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 18
rs 7.6666
c 0
b 0
f 0
cc 10
nc 7
nop 0

How to fix   Complexity   

Long Method

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:

1
<?php
2
/**
3
 * Base mail scanner action file.
4
 *
5
 * @package App
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Mariusz Krzaczkowski <[email protected]>
10
 * @author    Radosław Skrzypczak <[email protected]>
11
 */
12
13
namespace App\Mail\ScannerAction;
14
15
use App\Mail\RecordFinder;
16
17
/**
18
 * Base mail scanner action class.
19
 */
20
class OpenHelpDesk extends Base
21
{
22
	/** {@inheritdoc} */
23
	public static $priority = 4;
24
25
	/** {@inheritdoc} */
26
	public function process(): void
27
	{
28
		$scanner = $this->message;
29
		if ($this->checkExceptions() || \App\Mail\Message\Base::MAIL_TYPE_RECEIVED !== $scanner->getMailType() || !($prefix = RecordFinder::getRecordNumberFromString($this->message->getSubject(), 'HelpDesk')) || !($id = \App\Record::getIdByRecordNumber($prefix, 'HelpDesk'))) {
30
			return;
31
		}
32
		$recordModel = \Vtiger_Record_Model::getInstanceById($id, 'HelpDesk');
33
		if ('Wait For Response' === $recordModel->get('ticketstatus') && !empty(\Config\Modules\OSSMailScanner::$helpdeskBindNextWaitForResponseStatus)) {
0 ignored issues
show
Bug introduced by
The type Config\Modules\OSSMailScanner was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34
			$recordModel->set('ticketstatus', \Config\Modules\OSSMailScanner::$helpdeskBindNextWaitForResponseStatus);
35
		} elseif (($ticketStatus = array_flip(\Settings_SupportProcesses_Module_Model::getTicketStatusNotModify())) && isset($ticketStatus[$recordModel->get('ticketstatus')])) {
36
			$recordModel->set('ticketstatus', \Config\Modules\OSSMailScanner::$helpdeskBindOpenStatus);
37
		}
38
39
		if ($recordModel->getPreviousValue()) {
40
			$recordModel->save();
41
		}
42
43
		$this->message->setProcessData($this->getName(), ['crmid' => $recordModel->getId()]);
44
	}
45
}
46