Passed
Push — developer ( 6ab04f...7f264c )
by Radosław
31:41 queued 13:45
created

GroupField   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 6 2
A operatorOgr() 0 4 1
1
<?php
2
/**
3
 * Group 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    Adrian Kon <[email protected]>
10
 */
11
12
namespace App\Conditions\QueryFields;
13
14
class GroupField extends BaseField
15
{
16
	/** {@inheritdoc} */
17
	public function getValue()
18
	{
19
		if (\is_array($this->value)) {
20
			return $this->value;
21
		}
22
		return explode('##', $this->value);
23
	}
24
25
	/**
26
	 * Currently logged-in user groups.
27
	 *
28
	 * @return array
29
	 */
30
	public function operatorOgr(): array
31
	{
32
		$groups = \App\Fields\Owner::getInstance($this->getModuleName())->getGroups(false, 'private');
33
		return [$this->getColumnName() => \array_keys($groups)];
34
	}
35
}
36