Passed
Push — developer ( b71d85...a26ac2 )
by Radosław
18:42
created

MultiEmailField::getOperator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * MultiEmail Query Field Class.
4
 *
5
 * @package UIType
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Arkadiusz Adach <[email protected]>
10
 * @author    Radosław Skrzypczak <[email protected]>
11
 */
12
13
namespace App\Conditions\QueryFields;
14
15
/**
16
 * MultiEmail Query Field Class.
17
 */
18
class MultiEmailField extends BaseField
19
{
20
	/** @var string Separator. */
21
	protected $separator = ',';
22
23
	/** {@inheritdoc} */
24
	public function getValue()
25
	{
26
		$valueArray = array_filter(explode($this->separator, $this->value));
27
		if (\in_array($this->operator, ['e', 'n'])) {
28
			foreach ($valueArray as $key => $value) {
29
				$valueArray[$key] = "\"{$value}\"";
30
			}
31
		}
32
33
		return $valueArray;
34
	}
35
36
	/** {@inheritdoc} */
37
	public function getOperator(): string
38
	{
39
		return 'a' === $this->operator ? 'c' : $this->operator;
40
	}
41
42
	/** {@inheritdoc} */
43
	public function operatorE(): array
44
	{
45
		return ['or like', $this->getColumnName(), $this->getValue()];
46
	}
47
48
	/** {@inheritdoc} */
49
	public function operatorN(): array
50
	{
51
		return ['not like', $this->getColumnName(), $this->getValue()];
52
	}
53
54
	/** {@inheritdoc} */
55
	public function operatorC(): array
56
	{
57
		return $this->operatorE();
58
	}
59
60
	/** {@inheritdoc} */
61
	public function operatorK(): array
62
	{
63
		return $this->operatorN();
64
	}
65
}
66