Passed
Push — developer ( 6b5868...bed0f9 )
by Radosław
22:42 queued 03:39
created

LinkByFields   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 12
c 1
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 16 6
1
<?php
2
/**
3
 * Base mail scanner action file.
4
 *
5
 * @package App
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Mariusz Krzaczkowski <[email protected]>
10
 */
11
12
namespace App\Mail\ScannerAction;
13
14
/**
15
 * Base mail scanner action class.
16
 */
17
class LinkByFields extends Base
18
{
19
	/** {@inheritdoc} */
20
	public static $priority = 3;
21
22
	/** {@inheritdoc} */
23
	public function process(): void
24
	{
25
		$scanner = $this->scannerEngine;
26
		if (empty($scanner->processData['CreatedMail']) || false === $scanner->getMailCrmId()) {
27
			return;
28
		}
29
		$returnIds = [];
30
		if ($ids = $scanner->findRelatedRecords(true)) {
31
			$relationModel = new \OSSMailView_Relation_Model();
32
			foreach ($ids as $id) {
33
				if ($relationModel->addRelation($scanner->getMailCrmId(), $id, $scanner->get('date'))) {
0 ignored issues
show
Bug introduced by
$scanner->getMailCrmId() of type array is incompatible with the type integer expected by parameter $sourceRecordId of OSSMailView_Relation_Model::addRelation(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
				if ($relationModel->addRelation(/** @scrutinizer ignore-type */ $scanner->getMailCrmId(), $id, $scanner->get('date'))) {
Loading history...
34
					$returnIds[] = $id;
35
				}
36
			}
37
		}
38
		$scanner->processData['LinkByFields'] = $returnIds;
39
	}
40
}
41